libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

_pygit2.GitError: error loading known_hosts #1213

Closed jamesbernardi closed 2 months ago

jamesbernardi commented 1 year ago

Since upgrading to 1.12.0 this has been a recurring error with Salt Stack 3005

_pygit2.GitError: error loading known_hosts

Rolling back to v 1.11.1 fixes this issue

wwimberly commented 1 year ago

Ran into the same issue in 1.12.0 for salt 3006.0. Downgrading to 1.11.1 made things happy.

jdavid commented 1 year ago

Can you try with 1.12.2 ? There we bundle libssh2 1.11.0 which apparently fixes some compatibility issues with OpenSSL 3.0

wwimberly commented 1 year ago

I'm seeing the same behavior with pygit 1.12.2.

2023-06-28 14:58:53,833 [salt.utils.gitfs :1894][ERROR   ][12776] Error occurred fetching gitfs remote 'git@git-host:our-org/our-repo.git': error loading known_hosts: 
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/gitfs.py", line 1870, in _fetch
    fetch_results = origin.fetch(**fetch_kwargs)
  File "/opt/saltstack/salt/extras-3.10/pygit2/remote.py", line 140, in fetch
    payload.check_error(err)
  File "/opt/saltstack/salt/extras-3.10/pygit2/callbacks.py", line 98, in check_error
    check_error(error_code)
  File "/opt/saltstack/salt/extras-3.10/pygit2/errors.py", line 65, in check_error
    raise GitError(message)
_pygit2.GitError: error loading known_hosts: 
2023-06-28 14:58:55,370 [salt.utils.gitfs :1894][ERROR   ][12772] Error occurred fetching git_pillar remote 'master git@git-host:our-org/our-repo.git': error loading known_hosts: 
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/gitfs.py", line 1870, in _fetch
    fetch_results = origin.fetch(**fetch_kwargs)
  File "/opt/saltstack/salt/extras-3.10/pygit2/remote.py", line 140, in fetch
    payload.check_error(err)
  File "/opt/saltstack/salt/extras-3.10/pygit2/callbacks.py", line 98, in check_error
    check_error(error_code)
  File "/opt/saltstack/salt/extras-3.10/pygit2/errors.py", line 65, in check_error
    raise GitError(message)
_pygit2.GitError: error loading known_hosts:
root@syndic01:/var/log/salt# salt --versions
Salt Version:
          Salt: 3006.1

Python Version:
        Python: 3.10.11 (main, May  5 2023, 02:31:54) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       libgit2: 1.6.4
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: 1.12.2
  python-gnupg: 0.4.8
        PyYAML: 5.4.1
         PyZMQ: 23.2.0
        relenv: 0.12.3
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: ubuntu 22.04.2 jammy
        locale: utf-8
       machine: x86_64
       release: 5.15.0-71-generic
        system: Linux
       version: Ubuntu 22.04.2 jammy
OrangeDog commented 11 months ago

This is a problem with Salt's custom python environment. Using pygit2 1.12.0 in any other environment, including with Salt, works fine. https://github.com/saltstack/salt/issues/64345

Since 1.13 this now happens without Salt's custom python.

howbazaar commented 10 months ago

Is there a change that causes HOME to be determined at package load time? That is what I've observed.

dwoz commented 6 months ago

Wat this not fixed in 3006.3?