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

Gets stuck connecting via ssh #1224

Open
roman-r-m opened this issue Oct 20, 2024 · 1 comment
Open

Gets stuck connecting via ssh #1224

roman-r-m opened this issue Oct 20, 2024 · 1 comment

Comments

@roman-r-m
Copy link

Describe the bug

I'm having trouble getting an example from the docs work.
The command I'm running is as follows:

venv/bin/python -m pyinfra -vvv --debug inventory.py exec -- echo "hello world"
--> Loading config...
--> Loading inventory...
    [pyinfra_cli.inventory] Creating fake inventory...
    [pyinfra_cli.inventory] Checking possible group_data at: ...

--> Connecting to hosts...
    [pyinfra.connectors.ssh] Connecting to: 192.168.1.218 ({'allow_agent': False, 'look_for_keys': False, '_pyinfra_ssh_forward_agent': False, '_pyinfra_ssh_config_file': None, '_pyinfra_ssh_known_hosts_file': '...', '_pyinfra_ssh_strict_host_key_checking': 'accept-new', '_pyinfra_ssh_paramiko_connect_kwargs': None, 'username': '...', 'port': 22, 'timeout': 10, 'pkey': ...})
    [pyinfra.connectors.sshuserclient.client] Loading SSH config: None

And it gets stuck here, until I press Ctrl+C.
Then it suddenly connects (and indeed I see it in journalctl on the server):

^CExiting upon user request!
    [192.168.1.218] Connected

Then again nothing happens, until I Ctrl+C again and it terminates.

Firstly, not sure why it says Loading SSH config: None when I gave it path to the config, but more importanly why does it get stuck?
Any way to debug this further?

My inventory is

servers = [
    ('192.168.1.218',{
        'ssh_port': 22,
        'ssh_user': '...',
        'ssh_key': '...',
        'ssh_key_password': '',
        'ssh_known_hosts_file': '...'
    }),	
]

Meta

    System: Linux
      Platform: Linux-6.6.54-2-MANJARO-x86_64-with-glibc2.40
      Release: 6.6.54-2-MANJARO
      Machine: x86_64
    pyinfra: v3.1.1
      click: v8.1.7
      configparser: v7.1.0
      distro: v1.9.0
      gevent: v24.10.3
      jinja2: v3.1.4
      packaging: v24.1
      paramiko: v3.5.0
      python-dateutil: v2.9.0.post0
      pywinrm: v0.5.0
      setuptools: v75.2.0
      typeguard: v4.3.0
      typing-extensions: v4.12.2
    Executable: /home/roman/dev/homelab/venv/lib/python3.12/site-packages/pyinfra/__main__.py
    Python: 3.12.6 (CPython, GCC 14.2.1 20240805)

Debug log

  File "/home/roman/dev/homelab/venv/lib/python3.12/site-packages/pyinfra_cli/main.py", line 222, in cli
    _main(*args, **kwargs)
  File "/home/roman/dev/homelab/venv/lib/python3.12/site-packages/pyinfra_cli/main.py", line 348, in _main
    connect_all(state)
  File "/home/roman/dev/homelab/venv/lib/python3.12/site-packages/pyinfra/api/connect.py", line 27, in connect_all
    with progress_spinner(greenlet_to_host.values()) as progress:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/home/roman/dev/homelab/venv/lib/python3.12/site-packages/pyinfra/progress.py", line 146, in progress_spinner
    spinner_thread.join()
  File "/usr/lib/python3.12/threading.py", line 1149, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.12/threading.py", line 1169, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/roman/dev/homelab/venv/lib/python3.12/site-packages/gevent/thread.py", line 276, in acquire
    acquired = BoundedSemaphore.acquire(self, blocking, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/gevent/_semaphore.py", line 184, in gevent._gevent_c_semaphore.Semaphore.acquire
  File "src/gevent/_semaphore.py", line 263, in gevent._gevent_c_semaphore.Semaphore.acquire
  File "src/gevent/_semaphore.py", line 253, in gevent._gevent_c_semaphore.Semaphore.acquire
  File "src/gevent/_abstract_linkable.py", line 521, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait
  File "src/gevent/_abstract_linkable.py", line 487, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 490, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 442, in gevent._gevent_c_abstract_linkable.AbstractLinkable._AbstractLinkable__wait_to_be_notified
  File "src/gevent/_abstract_linkable.py", line 451, in gevent._gevent_c_abstract_linkable.AbstractLinkable._switch_to_hub
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
gevent.exceptions.LoopExit: This operation would block forever
        Hub: <Hub '' at 0x7f69e6171580 epoll default pending=0 ref=0 fileno=3 resolver=<gevent.resolver.thread.Resolver at 0x7f69e80567b0 pool=<ThreadPool at 0x7f69e5f509e0 tasks=0 size=0 maxsize=10 hub=<Hub at 0x7f69e6171580 thread_ident=0x7f69e9850b80>>> threadpool=<ThreadPool at 0x7f69e5f509e0 tasks=0 size=0 maxsize=10 hub=<Hub at 0x7f69e6171580 thread_ident=0x7f69e9850b80>> thread_ident=0x7f69e9850b80>
        Handles:
[]
@roman-r-m
Copy link
Author

Looks like it's paramico that is the culprit here. Will check its repo.

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

1 participant