saltstack / saltstack/salt

[BUG] saltenv variable always equals `base` in reactor SLS

Open
#63,600 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
The saltenv variable is always set to base in reactor SLSs, even when the reactor SLS is loaded from another environment.

Setup
master.conf:

reactor:
  - '<some tag>':
    - salt://reactor/mysls?saltenv=myenv

/reactor/mysls.sls:

<id>:
  runner.state.orchestrate:
    - args:
      - mods: orch.myorch
      - saltenv: "{{ saltenv }}"  # This always results in the orchestration SLS from `base` being loaded according to the debug logs. Directly setting it to `myenv` works as expected.

Expected behavior
saltenv should be equal to the environment where the reactor SLS was loaded from (myenv in the above). Alternatively, if these are not related in the way I assume they are, another variable should be provided so the saltenv can be propagated automatically.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3005.1

Dependency Versions:
          cffi: 1.15.1
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       libgit2: 1.5.0
      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.16.0
        pygit2: 1.11.1
        Python: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
  python-gnupg: Not Installed
        PyYAML: 6.0
         PyZMQ: 20.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.3

System Versions:
          dist: ubuntu 22.04 Jammy Jellyfish
        locale: utf-8
       machine: aarch64
       release: 5.15.0-1028-aws
        system: Linux
       version: Ubuntu 22.04 Jammy Jellyfish

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

Start with the reactor mapping in master.conf and /reactor/mysls.sls, then trace how runner.state.orchestrate receives the saltenv value from the reactor context. Reproduce the example with myenv and confirm that the orchestration SLS is loaded from myenv rather than base; done means the environment is propagated or an explicitly documented equivalent variable is available.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.