Skip to content

Fix issue 61614#61648

Merged
Ch3LL merged 5 commits into
saltstack:masterfrom
msteed:issue-61614
Feb 24, 2022
Merged

Fix issue 61614#61648
Ch3LL merged 5 commits into
saltstack:masterfrom
msteed:issue-61614

Conversation

@msteed

@msteed msteed commented Feb 16, 2022

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes state.show_state_usage not fail when a saltenv contains states but is not referenced in any topfile.

What issues does this PR fix or reference?

Fixes: #61614

Previous Behavior

Create a saltenv with a state and an empty topfile. Then salt \* state.show_state_usage results in:

self = <salt.state.HighState object at 0x7f1b306c7550>

    def compile_state_usage(self):
        """
        Return all used and unused states for the minion based on the top match data
        """
        err = []
        top = self.get_top()
        err += self.verify_tops(top)

        if err:
            return err

        matches = self.top_matches(top)
        state_usage = {}

        for saltenv, states in self.avail.items():
            env_usage = {
                "used": [],
                "unused": [],
                "count_all": 0,
                "count_used": 0,
                "count_unused": 0,
            }

            env_matches = matches.get(saltenv)

            for state in states:
                env_usage["count_all"] += 1
>               if state in env_matches:
E               TypeError: argument of type 'NoneType' is not iterable

New Behavior

No failure

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@msteed msteed requested a review from a team as a code owner February 16, 2022 01:03
@msteed msteed requested review from Ch3LL and removed request for a team February 16, 2022 01:03
@Ch3LL Ch3LL added the Phosphorus v3005.0 Release code name and version label Feb 16, 2022
@Ch3LL Ch3LL merged commit 5f3c29a into saltstack:master Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Phosphorus v3005.0 Release code name and version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] state.show_state_usage stop working when using other than base environments (like when having SSE installed)

2 participants