Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find object on role create #484

Closed
conor-f opened this issue Sep 9, 2022 · 4 comments
Closed

Could not find object on role create #484

conor-f opened this issue Sep 9, 2022 · 4 comments

Comments

@conor-f
Copy link

conor-f commented Sep 9, 2022

When trying to create a role and assign default properties, the response is: splunklib.binding.HTTPError: HTTP 404 Not Found -- Could not find object id=XXXXXXXX

However, the role appears to have been created correctly.

To Reproduce

>>> import splunklib.client as client
>>> service = client.connect(host="XXXXXXXX", port=8089, username="XXXXXXXX", password="XXXXXXXX", token=None, app="search")
>>> service.roles.create("bugreport-role-name", imported_roles=["XXXXXXXX"], srchIndexesAllowed=["XXXXXXXX"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/client.py", line 3510, in create
    response = self.get(name)
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/client.py", line 1668, in get
    return super(Collection, self).get(name, owner, app, sharing, **query)
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/client.py", line 766, in get
    **query)
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/binding.py", line 290, in wrapper
    return request_fun(self, *args, **kwargs)
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/binding.py", line 71, in new_f
    val = f(*args, **kwargs)
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/binding.py", line 686, in get
    response = self.http.get(path, all_headers, **query)
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/binding.py", line 1194, in get
    return self.request(url, { 'method': "GET", 'headers': headers })
  File "/home/conor/Code/splunk/.env_python3.6/lib/python3.6/site-packages/splunklib/binding.py", line 1255, in request
    raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 404 Not Found -- Could not find object id=bugreport-role-name

Expected behavior
No error and the Role is returned.

Splunk:

  • Version: 8.0.3
  • OS: Ubuntu 20.04
  • Deployment: Distributed

SDK:

  • Version: 1.6.14
  • Language Runtime Version: Python 3.6
  • OS: Ubuntu 20.04

Additional context
Pretty sure this also happens when creating users too. And some other resources

@ashah-splunk
Copy link
Contributor

@conor-f I would request you to use the latest Python SDK v1.7.2. Please let us know if the issue still exists. Thanks!

@conor-f
Copy link
Author

conor-f commented Sep 20, 2022

Yes, the issue still exists:

conor@Conor-laptop:~ $ python3 -m pip freeze | grep "splunk-sdk" 
/usr/lib/python3/dist-packages/secretstorage/dhcrypto.py:15: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
  from cryptography.utils import int_from_bytes
/usr/lib/python3/dist-packages/secretstorage/util.py:19: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
  from cryptography.utils import int_from_bytes
splunk-sdk==1.7.2
conor@Conor-laptop:~ $ python3                                  
Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import splunklib.client as client
>>> service = client.connect(host="XXXXXXXX", port=XXXXXXXX, username="XXXXXXXX", password="XXXXXXXX", token=None, app="search")
>>> service.roles.create("bugreport-role-name-again", imported_roles=["external_user_role"], srchIndexesAllowed=["logs"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/client.py", line 3640, in create
    response = self.get(name)
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/client.py", line 1774, in get
    return super(Collection, self).get(name, owner, app, sharing, **query)
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/client.py", line 862, in get
    return self.service.get(path,
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/binding.py", line 291, in wrapper
    return request_fun(self, *args, **kwargs)
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/binding.py", line 72, in new_f
    val = f(*args, **kwargs)
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/binding.py", line 697, in get
    response = self.http.get(path, all_headers, **query)
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/binding.py", line 1230, in get
    return self.request(url, { 'method': "GET", 'headers': headers })
  File "/home/conor/.local/lib/python3.8/site-packages/splunklib/binding.py", line 1302, in request
    raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 404 Not Found -- Could not find object id=bugreport-role-name-again
>>> "bugreport-role-name-again" in service.roles
True
>>> service.roles.get("bugreport-role-name-again")
{'status': 200, 'reason': 'OK', 'headers': [('Date', 'Tue, 20 Sep 2022 10:33:35 GMT'), ('Content-Type', 'text/xml; charset=UTF-8'), ('Content-Length', '7170'), ('Connection', 'close'), ('Expires', 'Thu, 26 Oct 1978 00:00:00 GMT'), ('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0'), ('X-Content-Type-Options', 'nosniff'), ('Vary', 'Cookie, Authorization'), ('Set-Cookie', 'splunkd_8089=rFtpjAAAAjFA4128H_YrkwuGB3h8HrwWvVVeI2a3gRCfGbk^saaaoz9C8u4U_Tm0dlYetButBdqhMCd6YZo6X80F9BRHnuKHi1sRJJF9nna3Z3C0OHW6lA3; Path=/; Secure; HttpOnly; Max-Age=3600; Expires=Tue, 20 Sep 2022 11:33:35 GMT'), ('X-Frame-Options', 'SAMEORIGIN'), ('Server', 'Splunkd')], 'body': <splunklib.binding.ResponseReader object at 0x7fcb655f1700>}

@ashah-splunk
Copy link
Contributor

Hi @conor-f, we are not able to reproduce the issue. We would request you to try adding a sleep just before the line #3640. Please let us know if this helps.
We think the issue is due to time taken to sync search-heads within the distributed system when a new role is created.

@ashah-splunk
Copy link
Contributor

Closing the Issue as we haven't received any response. @conor-f please reopen the Issue if you still facing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants