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

Skip failing anti-affinity rules if at least one valid rule is found. #373

Merged
merged 2 commits into from
Aug 3, 2022

Conversation

dhaus67
Copy link
Contributor

@dhaus67 dhaus67 commented Jul 8, 2022

Description

When adding more verbose errors to no-anti-affinity check, we remove the short-circuiting on the first valid anti-affinity rule.
However, we should short-circuit on the first anti-affinity rule, as this is the expected behavior of the check.

Fixes #369

…rs if no anti-affinity rule could be validated.
@dhaus67 dhaus67 requested a review from viswajithiii July 8, 2022 00:53
@dhaus67 dhaus67 requested a review from janisz as a code owner July 8, 2022 00:53
}
foundIssues = append(foundIssues, diagnostic.Diagnostic{
Message: err.Error(),
})
}
return foundIssues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return nil if no issues are found, which is wrong. (Which also suggests we need some unit tests here 😅)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, but what would the expected behavior be if we didn't find any issues?

We are already short-circuiting if no anti-affinity rule is created beforehand.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, just saw that short-circuit. Well, we need to enhance it so that it also handles the case where podAntiAffinity is not nil, but both the arrays ("required" and "preferred") are empty. If we short-circuit in that case as well, then we should be good.

Copy link
Contributor

@viswajithiii viswajithiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment

@dhaus67 dhaus67 enabled auto-merge (squash) August 3, 2022 14:12
@dhaus67 dhaus67 dismissed viswajithiii’s stale review August 3, 2022 14:13

Dismissing since we got an approval from Tomek. If there's anything else required, we can create another PR for it.

@dhaus67 dhaus67 merged commit 2a589b7 into stackrox:main Aug 3, 2022
abrad3 pushed a commit to abrad3/kube-linter that referenced this pull request Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Lint fails on no-anti-affinity check in 0.3.0 where it succeeded in 0.2.6
3 participants