stackrox / kube-linter

KubeLinter is a static analysis tool that checks Kubernetes YAML files and Helm charts to ensure the applications represented in them adhere to best practices.
https://docs.kubelinter.io/
Apache License 2.0
2.83k stars 228 forks source link

feature: add support to keda scaledobject v1alpha1 #711

Closed jonathanmdr closed 4 months ago

jonathanmdr commented 5 months ago

I believe it provides support to pdb-min-available when the Replica number is controlled via Keda ScaledObject

I closed erroneously this PR: https://github.com/stackrox/kube-linter/pull/703

jonathanmdr commented 5 months ago

Nice work! On the first look everything is fine but on second there is something missing.

  1. You correctly added keda to extract but it's never called in unit test
  2. Could you add good/bad tests to verify it's really working
  3. You need to register keda scheme in https://github.com/stackrox/kube-linter/blob/e0225f476a85c4533eab934105c63f44e9d95a50/pkg/lintcontext/parse_yaml.go#L47

No related to this PR but we need to use --fail-on-invalid-resource in e2e as in your case it will highlight the error

pdb-min-available.yaml: (object: <no namespace>/ /, Kind=) failed to decode: no kind "ScaledObject" is registered for version "keda.sh/v1alpha1" in scheme "pkg/runtime/scheme.go:100" (check: failed-to-load-object, remediation: Confirm that the file is accessible and is valid k8s yaml.)

Well noted!

I adjusted my implementation and unit tests writing good/bad scenarios for this functionality!

If there's any other feedback, we're happy to follow up on it πŸ˜„

janisz commented 4 months ago

Nice, thank you. Could you rebase?

jonathanmdr commented 4 months ago

Nice, thank you. Could you rebase?

Sure, rebase applied!

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (cd1e926) 72.36% compared to head (bf75310) 72.37%.

:exclamation: Current head bf75310 differs from pull request most recent head 4ef3f07. Consider uploading reports for the commit 4ef3f07 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #711 +/- ## ========================================== + Coverage 72.36% 72.37% +0.01% ========================================== Files 45 45 Lines 1936 1937 +1 ========================================== + Hits 1401 1402 +1 Misses 421 421 Partials 114 114 ``` | [Flag](https://app.codecov.io/gh/stackrox/kube-linter/pull/711/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stackrox) | Coverage Ξ” | | |---|---|---| | [bats](https://app.codecov.io/gh/stackrox/kube-linter/pull/711/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stackrox) | `βˆ… <ΓΈ> (βˆ…)` | | | [unit](https://app.codecov.io/gh/stackrox/kube-linter/pull/711/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stackrox) | `72.37% <100.00%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stackrox#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

janisz commented 4 months ago

@jonathanmdr Thanks! In the meantime dependabot updated k8s so I updated your PR.