Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 61614 #61648

Merged
merged 5 commits into from
Feb 24, 2022
Merged

Fix issue 61614 #61648

merged 5 commits into from
Feb 24, 2022

Conversation

msteed
Copy link
Contributor

@msteed msteed commented Feb 16, 2022

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
2 participants