spotify / snakebite

A pure python HDFS client
Apache License 2.0
856 stars 216 forks source link

snakebite.errors.RequestError: javax.security.sasl.SaslException Client mechanism is malformed #238

Closed dcapwell closed 6 years ago

dcapwell commented 6 years ago

Related-To: https://github.com/spotify/snakebite/issues/175

I am trying to get snakebite to work (for Airflow) in a container environment and having a few issues. I removed Airflow (target client) from the picture and created this basic script to test things out

$ cat check_snakebite.py
from snakebite.client import Client, AutoConfigClient, HAClient, Namenode

c = HAClient([Namenode('host1', 8020), Namenode('host2', 8020)],
        hdfs_namenode_principal='hdfs/_HOST@EXAMPLE.COM',
        effective_user='user/not.real.hostname@EXAMPLE.COM',
        use_sasl=True)

for x in c.ls(['/']):
  print x

I have two clusters I am testing out; a hadoop cluster I created, and one created by CDH. When I run the above script on a physical node (host portion of principle matches hostname), it works just fine against my test cluster. When I move the script into a docker container and call the CDH cluster, I get the below exception. Since this is in Docker, the hostname doesn't match principle (nor do I have permissions to fix the hostname).

From the same host, using the hadoop libraries work fine, and so does code we have written in java. Its only when I try to use snakebite that this fails.

Thanks for your time reading this issue

bash-4.3$ python check_snakebite.py
Traceback (most recent call last):
  File "check_snakebite.py", line 8, in <module>
    for x in c.ls(['/']):
  File "/python/lib/python2.7/site-packages/snakebite/client.py", line 1542, in wrapped
    self.__handle_request_error(e)
  File "/python/lib/python2.7/site-packages/snakebite/client.py", line 1540, in wrapped
    yield results.next()
  File "/python/lib/python2.7/site-packages/snakebite/client.py", line 168, in ls
    recurse=recurse):
  File "/python/lib/python2.7/site-packages/snakebite/client.py", line 1214, in _find_items
    fileinfo = self._get_file_info(path)
  File "/python/lib/python2.7/site-packages/snakebite/client.py", line 1342, in _get_file_info
    return self.service.getFileInfo(request)
  File "/python/lib/python2.7/site-packages/snakebite/service.py", line 40, in <lambda>
    rpc = lambda request, service=self, method=method.name: service.call(service_stub_class.__dict__[method], request)
  File "/python/lib/python2.7/site-packages/snakebite/service.py", line 46, in call
    return method(self.service, controller, request)
  File "/python/lib/python2.7/site-packages/google/protobuf/service_reflection.py", line 267, in <lambda>
    self._StubMethod(inst, method, rpc_controller, request, callback))
  File "/python/lib/python2.7/site-packages/google/protobuf/service_reflection.py", line 284, in _StubMethod
    method_descriptor.output_type._concrete_class, callback)
  File "/python/lib/python2.7/site-packages/snakebite/channel.py", line 442, in CallMethod
    self.get_connection(self.host, self.port)
  File "/python/lib/python2.7/site-packages/snakebite/channel.py", line 248, in get_connection
    sasl_connected = sasl.connect()
  File "/python/lib/python2.7/site-packages/snakebite/rpc_sasl.py", line 98, in connect
    res = self._recv_sasl_message()
  File "/python/lib/python2.7/site-packages/snakebite/rpc_sasl.py", line 79, in _recv_sasl_message
    sasl_response = self._trans.parse_response(bytestream, RpcSaslProto)
  File "/python/lib/python2.7/site-packages/snakebite/channel.py", line 418, in parse_response
    self.handle_error(header)
  File "/python/lib/python2.7/site-packages/snakebite/channel.py", line 421, in handle_error
    raise RequestError("\n".join([header.exceptionClassName, header.errorMsg]))
snakebite.errors.RequestError: javax.security.sasl.SaslException
Client mechanism is malformed
dcapwell commented 6 years ago
$ pip freeze | grep python-krbV
python-krbV==1.0.90
$ pip freeze | grep snake
snakebite==2.11.0
$ pip freeze | grep sasl
sasl==0.2.1
kockockockoc commented 6 years ago

Run snakebite in debug mode:

_DEBUG:snakebite.rpc_sasl:Available mechs: DIGEST-MD5,GSSAPI DEBUG:snakebite.rpcsasl:Chosen mech:

Empty "Chosen mech".

https://github.com/spotify/snakebite/issues/175#issuecomment-237251283

I was having the same problem as in the OP and for me the actual problem turned out to be missing the cyrus-sasl-md5 and(/or?) cyrus-sasl-gssapi packages. Installing these packages solved it.

dcapwell commented 6 years ago

Sorry, should close

So turns out that the way our package installs works is based off relocation which doesn't work with Cyrus sasl since plugin directory is a compile config.

I was able to resolve this by recompile Cyrus sasl