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

Use Current ioloop in SyncWrapper #67131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frebib
Copy link
Contributor

@frebib frebib commented Jan 7, 2025

What does this PR do?

A new ioloop is created for each SyncWrapper, but is not swapped in automatically (see make_current=False for Tornado) anymore - this means that the context manager (current_ioloop) is needed to access that ioloop for the purposes of the synchronus execution.

This also needs to be backported to 3007.x (3007.2)

What issues does this PR fix or reference?

Fixes #66775

Merge requirements satisfied?

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

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.

See GitHub's page on GPG signing for more information about signing commits with GPG.

A new ioloop is created for each SyncWrapper, but is not swapped in
automatically (see make_current=False for Tornado) anymore - this means
that the context manager (current_ioloop) is needed to access that
ioloop for the purposes of the synchronus execution.

Signed-off-by: Joe Groocock <[email protected]>
@frebib frebib requested a review from a team as a code owner January 7, 2025 09:57
@frebib
Copy link
Contributor Author

frebib commented Jan 7, 2025

We hit this issue in a slightly different manner to the linked bug ticket, but it's the same problem

[ERROR   ] Rendering exception occurred
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/templates.py", line 471, in render_jinja_tmpl
    output = template.render(**decoded_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 162, in get_source
    self.check_cache(_template)
  File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 116, in check_cache
    ret = self.cache_file(template)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 108, in cache_file
    fcl = self.file_client()
          ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 97, in file_client
    self._file_client = salt.fileclient.get_file_client(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/fileclient.py", line 56, in get_file_client
    return {"remote": RemoteClient, "local": FSClient, "pillar": PillarClient}.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/fileclient.py", line 1130, in __init__
    self.channel = salt.channel.client.ReqChannel.factory(self.opts)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/channel/client.py", line 56, in factory
    return SyncWrapper(
           ^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/utils/asynchronous.py", line 76, in __init__
    self.obj = cls(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/channel/client.py", line 133, in factory
    auth = salt.crypt.AsyncAuth(opts, io_loop=io_loop)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/salt/crypt.py", line 697, in __new__
    auth.__singleton_init__(opts, io_loop=io_loop)
  File "/usr/lib/python3/dist-packages/salt/crypt.py", line 744, in __singleton_init__
    self._authenticate_future = tornado.concurrent.Future()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/events.py", line 677, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'MainThread'.

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] 3007.1 - salt-proxy - "there is no current event loop in thread"
1 participant