Description
A clear and concise description of what the bug is.
I have a custom execution module were I need to compile Pillars given a custom git branch. This is done by invoking salt.pillar.get_pillar. I had no troubles running this across many Salt versions (including 3002.9 currently), but upgrading to anything above 3003 (including 3005rc2), it errors out.
The reasoning why we're needing this call is that we have a gitfs backend, and need on-demand Pillar data compiled for whatever branch the user requires.
Trace:
The minion function caused an exception: Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/salt/metaproxy/proxy.py", line 479, in thread_return
return_data = minion_instance.executors[fname](
File "/usr/local/lib/python3.9/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/salt/loader/lazy.py", line 1228, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/salt/loader/lazy.py", line 1243, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/salt/executors/direct_call.py", line 10, in execute
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/salt/loader/lazy.py", line 149, in __call__
return self.loader.run(run_func, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/salt/loader/lazy.py", line 1228, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/salt/loader/lazy.py", line 1243, in _run_as
return _func_or_method(*args, **kwargs)
File "/var/cache/salt/proxy/extmods/some-proxy/modules/do.py", line 862, in config
master_pillar = get_pillar(ext=_ext_pillar_args(branch) if branch else None)
File "/var/cache/salt/proxy/extmods/some-proxy/modules/do.py", line 104, in get_pillar
ret = salt.pillar.get_pillar(
File "/usr/local/lib/python3.9/site-packages/salt/pillar/__init__.py", line 353, in compile_pillar
ret_pillar = self.channel.crypted_transfer_decode_dictentry(
File "/usr/local/lib/python3.9/site-packages/salt/utils/asynchronous.py", line 125, in wrap
raise exc_info[1].with_traceback(exc_info[2])
File "/usr/local/lib/python3.9/site-packages/salt/utils/asynchronous.py", line 131, in _target
result = io_loop.run_sync(lambda: getattr(self.obj, key)(*args, **kwargs))
File "/usr/local/lib/python3.9/site-packages/salt/ext/tornado/ioloop.py", line 459, in run_sync
return future_cell[0].result()
File "/usr/local/lib/python3.9/site-packages/salt/ext/tornado/concurrent.py", line 249, in result
raise_exc_info(self._exc_info)
File "<string>", line 4, in raise_exc_info
File "/usr/local/lib/python3.9/site-packages/salt/ext/tornado/gen.py", line 309, in wrapper
yielded = next(result)
File "/usr/local/lib/python3.9/site-packages/salt/channel/client.py", line 172, in crypted_transfer_decode_dictentry
self._package_load(self.auth.crypticle.dumps(load)),
File "/usr/local/lib/python3.9/site-packages/salt/crypt.py", line 1518, in dumps
toencrypt = self.PICKLE_PAD + salt.payload.dumps(obj)
File "/usr/local/lib/python3.9/site-packages/salt/payload.py", line 163, in dumps
return salt.utils.msgpack.packb(
File "/usr/local/lib/python3.9/site-packages/salt/utils/msgpack.py", line 133, in packb
return msgpack.packb(o, **_sanitize_msgpack_kwargs(kwargs))
File "/usr/local/lib/python3.9/site-packages/msgpack/__init__.py", line 38, in packb
return Packer(**kwargs).pack(o)
File "msgpack/_packer.pyx", line 294, in msgpack._cmsgpack.Packer.pack
File "msgpack/_packer.pyx", line 300, in msgpack._cmsgpack.Packer.pack
File "msgpack/_packer.pyx", line 297, in msgpack._cmsgpack.Packer.pack
File "msgpack/_packer.pyx", line 231, in msgpack._cmsgpack.Packer._pack
File "msgpack/_packer.pyx", line 285, in msgpack._cmsgpack.Packer._pack
File "/usr/local/lib/python3.9/site-packages/salt/payload.py", line 158, in ext_type_encoder
return dict(obj)
File "/usr/local/lib/python3.9/_collections_abc.py", line 826, in __iter__
yield from self._mapping
File "/usr/local/lib/python3.9/site-packages/salt/loader/context.py", line 97, in __iter__
return self.value().__iter__()
AttributeError: 'NoneType' object has no attribute '__iter__'
Setup
A Salt Master and a Proxy Minion (any flavour) running Salt 3003+, and a custom execution module with these functions:
def _ext_pillar_args(branch):
repo = "git@github.example.com:org/salt.git"
return dict(
git=[
{
"{} {}".format(branch, repo): [
{"env": "base"},
{"root": "salt/pillar"},
{"pubkey": "/path/to/key.pub"},
{"privkey": "/path/to/key.priv"},
]
}
]
)
def get_pillar(branch=None):
ext = _ext_pillar_args(branch) if branch else None
ret = salt.pillar.get_pillar(
__opts__, __grains__, __opts__["id"], __opts__.get("saltenv"), ext=ext
).compile_pillar()
return ret
Master configuration:
ext_pillar_first: true
ext_pillar:
- git:
- git@github.example.com:org/salt.git:
- root: salt/pillar
- pubkey: /path/to/key.pub
- privkey: /path/to/key.priv
This code has been running in production, and currently under 3002.9 perfectly fine.
Steps to Reproduce the behavior
- Put the code above into a custom execution module.
- Set up a Master with a gitfs backend and a Proxy Minion of any flavour.
- Execute
salt <tgt> custom_module.get_pillar
Expected behavior
I'd expect to get the pillar not the trace.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
root@salt:~# salt --versions-report
Salt Version:
Salt: 3004.2
Dependency Versions:
cffi: 1.15.1
cherrypy: unknown
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.0.3
libgit2: 1.4.3
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.4
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.15.0
pygit2: 1.9.2
Python: 3.9.13 (main, Jul 12 2022, 12:26:02)
python-gnupg: 0.4.9
PyYAML: 6.0
PyZMQ: 21.0.2
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.3
System Versions:
dist: debian 10 buster
locale: utf-8
machine: x86_64
release: 5.0.0-36-generic
system: Linux
version: Debian GNU/Linux 10 buster
Additional context
Add any other context about the problem here.
Description
A clear and concise description of what the bug is.
I have a custom execution module were I need to compile Pillars given a custom git branch. This is done by invoking
salt.pillar.get_pillar. I had no troubles running this across many Salt versions (including 3002.9 currently), but upgrading to anything above 3003 (including 3005rc2), it errors out.The reasoning why we're needing this call is that we have a gitfs backend, and need on-demand Pillar data compiled for whatever branch the user requires.
Trace:
Setup
A Salt Master and a Proxy Minion (any flavour) running Salt 3003+, and a custom execution module with these functions:
Master configuration:
This code has been running in production, and currently under 3002.9 perfectly fine.
Steps to Reproduce the behavior
salt <tgt> custom_module.get_pillarExpected behavior
I'd expect to get the pillar not the trace.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Additional context
Add any other context about the problem here.