saltstack / saltstack/salt

[BUG] Cannot call transactional-update from within transactional-update environment!

Open
#61,379 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
I get salt.exceptions.CommandExecutionError: Cannot call transactional-update from within transactional-update environment! whenever running the transactional-update module from within a state as described in the salt docs.

Setup

sls file

env: 
  module.run:
    - transactional_update.patch:
      - snapshot: continue

anotherEnv:
  module.run:
    - transactional_update.call: 
      - test.ping

yetAnotherEnv:
  module.run:
    - transactional_update.pkg_install: 
      - pkg: cockpit

output

----------
          ID: env
    Function: module.run
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3.8/site-packages/salt/state.py", line 2186, in call
                  ret = self.states[cdata["full"]](
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1241, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2276, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2291, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2324, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/utils/decorators/__init__.py", line 738, in _decorate
                  return self._call_function(kwargs)
                File "/usr/lib/python3.8/site-packages/salt/utils/decorators/__init__.py", line 352, in _call_function
                  return self._function(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/states/module.py", line 427, in run
                  func_ret = _call_function(
                File "/usr/lib/python3.8/site-packages/salt/states/module.py", line 473, in _call_function
                  mret = salt.utils.functools.call_function(__salt__[name], *func_args, **func_kwargs)
                File "/usr/lib/python3.8/site-packages/salt/utils/functools.py", line 159, in call_function
                  return salt_function(*function_args, **function_kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1241, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2276, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2291, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/modules/transactional_update.py", line 708, in patch
                  return _cmd(cmd)
                File "/usr/lib/python3.8/site-packages/salt/modules/transactional_update.py", line 355, in _cmd
                  raise salt.exceptions.CommandExecutionError(result["stderr"])
              salt.exceptions.CommandExecutionError: Cannot call transactional-update from within transactional-update environment!
     Started: 08:08:28.708946
    Duration: 87.331 ms
     Changes:
----------
          ID: anotherEnv
    Function: module.run
      Result: False
     Comment: 'transactional_update.call' failed: Cannot call transactional-update from within transactional-update environment!
     Started: 08:08:28.796581
    Duration: 12.204 ms
     Changes:
----------
          ID: yetAnotherEnv
    Function: module.run
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3.8/site-packages/salt/state.py", line 2186, in call
                  ret = self.states[cdata["full"]](
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1241, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2276, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2291, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2324, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/utils/decorators/__init__.py", line 738, in _decorate
                  return self._call_function(kwargs)
                File "/usr/lib/python3.8/site-packages/salt/utils/decorators/__init__.py", line 352, in _call_function
                  return self._function(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/states/module.py", line 427, in run
                  func_ret = _call_function(
                File "/usr/lib/python3.8/site-packages/salt/states/module.py", line 473, in _call_function
                  mret = salt.utils.functools.call_function(__salt__[name], *func_args, **func_kwargs)
                File "/usr/lib/python3.8/site-packages/salt/utils/functools.py", line 159, in call_function
                  return salt_function(*function_args, **function_kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1241, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2276, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2291, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.8/site-packages/salt/modules/transactional_update.py", line 774, in pkg_install
                  return _cmd(cmd)
                File "/usr/lib/python3.8/site-packages/salt/modules/transactional_update.py", line 355, in _cmd
                  raise salt.exceptions.CommandExecutionError(result["stderr"])
              salt.exceptions.CommandExecutionError: Cannot call transactional-update from within transactional-update environment!
     Started: 08:08:28.809032
    Duration: 10.264 ms
     Changes:

Steps to Reproduce the behavior

# salt-run fileserver.update
# salt '*' state.apply

Expected behavior
I expect the module to run from the state and produce results similar to calling the module from the command line like below.

# salt '*' transactional_update.call test.ping
hpe.verizon.net:
    True
thor.verizon.net:
    True

Versions Report

salt --versions-report
Salt Version:
          Salt: 3003.3

Dependency Versions:
          cffi: 1.15.0
      cherrypy: unknown
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: 1.3.0
      M2Crypto: 0.37.1
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: 3.11.0
  pycryptodome: Not Installed
        pygit2: 1.7.0
        Python: 3.8.10 (default, May 05 2021, 15:36:36) [GCC]
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 22.0.3
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: opensuse-microos 20210524
        locale: utf-8
       machine: x86_64
       release: 5.12.4-1-default
        system: Linux
       version: openSUSE MicroOS 20210524
  • I also had to install the transactional update module on the minions with transactional-update pkg install salt-transactional-update
  • I also added the following file to switch to the new module format on my minions
name:/etc/salt/minion.d # cat module.conf
use_superseded:
  - module.run

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect salt/modules/transactional_update.py, especially _cmd and patch, call, and pkg_install; compare their invocation from salt/states/module.py. Reproduce with the supplied SLS and state.apply on openSUSE MicroOS, then verify the module works from a state with results matching direct transactional_update.call.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.