saltstack / saltstack/salt

[BUG] state.highstate test=True saltenv=None against a Salt GitFS server causes modules from random branches to be fetched rather than from the configured saltenv

Open
#57,944 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

(With latest Salt 3001)

I encountered a curious situation with Salt. The setup:

  • Salt master with GitFS and hundreds of branches.
  • Salt API receiving requests.
  • API client requesting state.highstate test=True from Salt minions.
  • Clients all configured with topfile merge strategy same and with saltenv = base.

I was encountering the weirdest thing. Every time the API client hit the endpoint, test-mode highstate started, modules were synced by the minions (this by itself is weird, but that's another matter), and after that, all the minions had the wrong modules. It took a saltutil.sync_all to correct that bad situation.

It was only when we discovered that our API client was sending the kwarg saltenv: null as part of the kwarg dictionary, that we connected the dots. Whenever the API client sends the request for test highstate with that specific kwarg, the saltenv: null parameter is relayed as-is by the Salt master bus to the minions, which in turn causes the minions to hit every single branch known to the GitFS-enabled master, fetching modules from the wrong branch, rather than from the configured base branch.

This is weird. The code for state.highstate clearly states:

    if "saltenv" in kwargs:
        opts["saltenv"] = kwargs["saltenv"]

So in this case the saltenv key/value in the opts dictionary gets set to None. This should be expanded to be a check for if "saltenv" in kwargs and kwargs["saltenv"]. Anywhere saltenv and pillarenv are accepted, that is the check that should be done.

I get the feeling that invalid values should not cause malfunctions of this sort.

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 in the state.highstate handling described in the issue and trace how saltenv and pillarenv values are passed through the master to GitFS-backed minions. Reproduce the API request with saltenv set to null, then verify that test-mode highstate does not fetch modules from unrelated branches and that the configured base environment remains effective.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.