question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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

See original GitHub issue

(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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jlsjonascommented, Dec 8, 2020

It appears that the same (if not a very similar) issue appears when using the cli to do a state apply without explicitly defining a saltenv; the minion was reporting lacking top files in several branches (branches that predate our salt setup); while I (also) expected it to use the base branch (default_top: base is set, along with top_file_merging_strategy: same) noticed the issue on 3002.2

1reaction
sagetheragecommented, Sep 15, 2020

Oh it’s simple to replicate: use the Salt API to submit a state.highstate and send saltenv=None in the kwargs of the API payload. That’s all you need to do.

The version is the very latest stable Salt on Ubuntu Xenial as published in the official Salt repository.

Yes, we ask for the report so that it isn’t a hunt for the exact version at the time of writing the issue. On July 23, 2020 the latest version likely was 3001, can you confirm @Rudd-O?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Trouble importing macro with gitfs and using saltenv
My Salt state fails to render, when specifying saltenv because it can't find the sls file that contains the macro definition.
Read more >
Git Fileserver Backend Walkthrough
This walkthrough assumes basic knowledge of Salt. To get up to speed, check out the Salt Walkthrough. The gitfs backend allows Salt to...
Read more >
Automate Static Site Deployments with Salt and Git
This guide will walk through the deployment of a static site using SaltStack, which is a flexible configuration management system.
Read more >
Can't get gitfs to work with github. It can't find top.sls
For some reason salt is unable to find the top.sls and I just can't seem to figure ... Output from: salt-call state.apply test=true...
Read more >
git - Salt top.sls does not update on `salt-run fileserver. ...
The reason for the error is that salt considers all branches, then merges all (!) branches to compile the final top.sls. I had...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found