saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
13.98k stars 5.47k forks source link

[BUG] states from gitfs fail with AttributeError: '_pygit2.Blob' object has no attribute 'oid' with pygit2 1.15.0 #66590

Open denschub opened 1 month ago

denschub commented 1 month ago

Description Using pygit2, the salt-master has trouble reading the gitfs repo used for the states. There's an exception:

salt-master[23426]: [ERROR   ] Error in function _file_hash:
salt-master[23426]: Traceback (most recent call last):
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/master.py", line 2087, in run_func
salt-master[23426]:     ret = getattr(self, func)(load)
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/fileserver/__init__.py", line 658, in file_hash
salt-master[23426]:     return self.__file_hash_and_stat(load)[0]
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/fileserver/__init__.py", line 642, in __file_hash>
salt-master[23426]:     fnd = self.find_file(
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/fileserver/__init__.py", line 600, in find_file
salt-master[23426]:     fnd = self.servers[fstr](path, saltenv, **kwargs)
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 160, in __call__
salt-master[23426]:     ret = self.loader.run(run_func, *args, **kwargs)
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1233, in run
salt-master[23426]:     return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1248, in _run_as
salt-master[23426]:     return _func_or_method(*args, **kwargs)
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/fileserver/gitfs.py", line 161, in find_file
salt-master[23426]:     return _gitfs().find_file(path, tgt_env=tgt_env, **kwargs)
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/utils/gitfs.py", line 3110, in find_file
salt-master[23426]:     blob, blob_hexsha, blob_mode = repo.find_file(repo_path, tgt_env)
salt-master[23426]:   File "/opt/salt/lib/python3.10/site-packages/salt/utils/gitfs.py", line 2134, in find_file
salt-master[23426]:     blob = self.repo[entry.oid]
salt-master[23426]: AttributeError: '_pygit2.Blob' object has no attribute 'oid'

Setup (Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Please be as specific as possible and give set-up details.

Steps to Reproduce the behavior The relevant salt master config is just a

gitfs_remotes:
  - ssh://git@example.com/ops/salt-states.git

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) ```yaml Salt Version: Salt: 3007.0 Python Version: Python: 3.10.14 (main, Apr 3 2024, 21:30:09) [GCC 11.2.0] Dependency Versions: cffi: 1.16.0 cherrypy: unknown dateutil: 2.9.0.post0 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.4 libgit2: 1.8.1 looseversion: 1.3.0 M2Crypto: Not Installed Mako: Not Installed msgpack: 1.0.8 msgpack-pure: Not Installed mysql-python: Not Installed packaging: 24.0 pycparser: 2.22 pycrypto: Not Installed pycryptodome: 3.20.0 pygit2: 1.15.0 python-gnupg: 0.5.2 PyYAML: 6.0.1 PyZMQ: 26.0.3 relenv: 0.16.0 smmap: Not Installed timelib: 0.3.0 Tornado: 6.4 ZMQ: 4.3.5 Salt Package Information: Package Type: Not Installed System Versions: dist: arch locale: utf-8 machine: x86_64 release: 6.9.1-arch1-2 system: Linux version: Arch Linu ```

Additional context Add any other context about the problem here.

denschub commented 1 month ago

Ah, pygit2 1.15.0 is too new. 1.13.1 works. Oh well.

OrangeDog commented 1 month ago

This shouldn't be closed. Salt needs to update to support the new version.

denschub commented 1 month ago

I mean, this project has a history of "we don't care about anything except the versions we tested with", but sure, let's reopen.