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

[3007.x] Fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http #66330

Open
wants to merge 1 commit into
base: 3007.x
Choose a base branch
from

Conversation

krombel
Copy link

@krombel krombel commented Apr 9, 2024

What does this PR do?

It replaces HTTPClient by AsyncHTTPClient

What issues does this PR fix or reference?

Fixes #66194

Background

tornadoweb/tornado#2325 (comment)
==> might be caused by #64304

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

@krombel krombel requested a review from a team as a code owner April 9, 2024 07:46
@krombel krombel requested review from twangboy and removed request for a team April 9, 2024 07:46
@salt-project-bot-prod-environment salt-project-bot-prod-environment bot changed the title Fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http [master] Fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http Apr 9, 2024
@twangboy twangboy requested review from dwoz and removed request for twangboy April 9, 2024 17:21
@twangboy
Copy link
Contributor

Hey @krombel , since this effects 3007, would you mind rebasing this against the 3007.x branch?

@krombel krombel changed the base branch from master to 3007.x April 19, 2024 06:15
@salt-project-bot-prod-environment salt-project-bot-prod-environment bot changed the title [master] Fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http [3007.x] Fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http Apr 19, 2024
@krombel
Copy link
Author

krombel commented Apr 19, 2024

@twangboy done

@twangboy
Copy link
Contributor

@krombel Would you know how to write a test for this?

@ITJamie
Copy link
Contributor

ITJamie commented Apr 29, 2024

I attempted this patch but got this error:

    Data failed to compile:
----------
    Pillar failed to render with the following messages:
----------
    Failed to load ext_pillar netbox: '_asyncio.Future' object has no attribute 'code'
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__init__.py", line 1215, in ext_pillar
     ext = self._external_pillar_data(pillar, val, key)
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__init__.py", line 1135, in _external_pillar_data
     ext = self.ext_pillars[key](self.minion_id, pillar, **val)
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
     ret = self.loader.run(run_func, *args, **kwargs)
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
     return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
     return _func_or_method(*args, **kwargs)
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/netbox.py", line 1118, in ext_pillar
     nodes.extend(_get_devices(api_url, minion_id, headers, api_query_result_limit))
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/netbox.py", line 707, in _get_devices
     device_ret = salt.utils.http.query(
   File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/http.py", line 662, in query
     result_status_code = result.code

@krombel
Copy link
Author

krombel commented Apr 29, 2024

@twangboy Sadly no. There are no related tests (I could find and adapt) and I am not familiar with python testing...

@ITJamie After you mentioned it I somehow could reproduce it. I don't know why it worked in the first place but now I introduced the SyncWrapper which allows calling fetch() in a sync manner.

A "proper" fix would possibly be to make query an async function (so we can simply await download_client.fetch()) but I think this would be too much of work for this (intended small/simple ) bug fix without touching too much of code...

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

Successfully merging this pull request may close these issues.

[BUG] ext_pillar netbox not working after upgrade to 3007
3 participants