Isilon / isilon_hadoop_tools

Tools for Using Hadoop with OneFS
https://pypi.org/project/isilon-hadoop-tools/
MIT License
14 stars 21 forks source link

Hue user exists? #112

Open nickyruggs opened 1 year ago

nickyruggs commented 1 year ago

Even though its a new access zone the script is failing with an error that user Hue exists. Some kind of a race condition? Please review

Evidence:

[INFO] Creating the hue user with UID 714 on 10.231.155.200...
[WARNING] User 'hue' already exists
Traceback (most recent call last):
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/onefs.py", line 572, in _decorated
    return func(self, *args, **kwargs)
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/onefs.py", line 944, in create_user
    self._sdk.AuthApi(self._api_client).create_auth_user(
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isi_sdk_8_2_2/api/auth_api.py", line 480, in create_auth_user
    (data) = self.create_auth_user_with_http_info(auth_user, **kwargs)  # noqa: E501
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isi_sdk_8_2_2/api/auth_api.py", line 553, in create_auth_user_with_http_info
    return self.api_client.call_api(
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isi_sdk_8_2_2/api_client.py", line 341, in call_api
    return self.__call_api(resource_path, method,
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isi_sdk_8_2_2/api_client.py", line 173, in __call_api
    response_data = self.request(
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isi_sdk_8_2_2/api_client.py", line 383, in request
    return self.rest_client.POST(url,
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isi_sdk_8_2_2/rest.py", line 353, in POST
    return self.request("POST", url,
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isi_sdk_8_2_2/rest.py", line 236, in request
    raise ApiException(http_resp=r)
isi_sdk_8_2_2.rest.ApiException: (409)
Reason: Conflict
HTTP response headers: HTTPHeaderDict({'Date': 'Wed, 29 Mar 2023 15:55:07 GMT', 'Server': 'Apache', 'Allow': 'GET, POST, DELETE, HEAD', 'X-Frame-Options': 'sameorigin', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Strict-Transport-Security': 'max-age=31536000;', 'Content-Security-Policy': "default-src 'self' 'unsafe-inline' 'unsafe-eval' data:; script-src 'self' 'unsafe-eval'; style-src 'unsafe-inline' 'self'; ", 'Transfer-Encoding': 'chunked', 'Content-Type': 'application/json'})
HTTP response body: 
{
"errors" : 
[

{
"code" : "AEC_CONFLICT",
"message" : "User 'hue' already exists"
}
]
}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/identities.py", line 242, in create_user
    self.onefs.create_user(
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/onefs.py", line 592, in _decorated
    raise wrapped_exc from exc
isilon_hadoop_tools.onefs.APIError: User 'hue' already exists

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.local/bin/isilon_create_users", line 8, in <module>
    sys.exit(isilon_create_users())
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/cli.py", line 41, in decorated
    return func(*args, **kwargs)
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/_scripts.py", line 131, in isilon_create_users
    onefs_and_files.create_identities(identities)
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/identities.py", line 178, in create_identities
    iterate_identities(
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/identities.py", line 304, in iterate_identities
    create_user(user_name, pgroup_name)
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/identities.py", line 259, in create_user
    uid = self.onefs.uid_of_user(
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/onefs.py", line 572, in _decorated
    return func(self, *args, **kwargs)
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/onefs.py", line 1277, in uid_of_user
    return int(auth_users.users[0].uid.id.split(":")[1])
AttributeError: 'NoneType' object has no attribute 'id'
tucked commented 1 year ago

Thanks for the report!

Here's the juicy part:

  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/identities.py", line 259, in create_user
    uid = self.onefs.uid_of_user(
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/onefs.py", line 572, in _decorated
    return func(self, *args, **kwargs)
  File "/root/.local/pipx/venvs/isilon-hadoop-tools/lib/python3.8/site-packages/isilon_hadoop_tools/onefs.py", line 1277, in uid_of_user
    return int(auth_users.users[0].uid.id.split(":")[1])
AttributeError: 'NoneType' object has no attribute 'id'

The first line tells us the IHT correctly figured out that we got a "user already exists" error and tried to get the UID of the existing user (so that it could put the same UID into the client-side user-creation script). While trying to get the UID, though, this line raised an AttributeError (because auth_users.users[0].uid is unexpectedly None): https://github.com/Isilon/isilon_hadoop_tools/blob/65347f5c0715f50aab9110fbc33e99ef2b004ce3/src/isilon_hadoop_tools/onefs.py#L1277 That line has been there since the Python port was created. Given that:

I wonder if this is due to a change in a more recent version of OneFS 🤔 We do have a test for this, though, and it would have run against recent OneFS versions in the testing for #109. That may suggest this is a racy issue. The documentation does say uid is optional... Perhaps we should be looking at auth_users.users[0].id instead.

@nickyruggs,

  1. What is the version of the cluster this ran against?
  2. Does it reproduce consistently if you try the same command again?
  3. What version of IHT are you using?
nickyruggs commented 1 year ago

This was a physical cluster running 9.4 reproduced 3 times so far most recent version. and using python 3 and (the one above 3.8)

nickyruggs commented 1 year ago

update: I knew it was hue related....there is a user called hue in AD and AD was added to that zone when i ran the script. So of course hue already existed. Just re-ran without AD joined and it worked just fine. Maybe make a note in the documentation to run beofore adding AD or LDAP to the AZ.