`flux check` always returns 0
Describe the bug
I am creating a pipeline which automatically updates FluxCD via a pull request. I was running into some permissions issues, in which I found that flux check always returns with an exit code of 0 even if not all deployments were ready:
Note the first arrow points to the result of flux check --pre which is as expected since it says all checks passed. The second arrow points to the result of flux check which should return a non-zero status code since the checks failed.
Steps to reproduce
- Install Flux.
- Create a ServiceAccount missing some permissions required for
flux checkto run (reference https://github.com/fluxcd/flux2/discussions/5217#discussioncomment-12344858). - Run
flux check. - Run
echo $?to see the status code.
Expected behavior
echo $? should return a non-zero status code if the result is "check failed".
Screenshots and recordings
No response
OS / Distro
Ubuntu 22.04
Flux version
v2.5.1
Flux check
► checking prerequisites ✔ Kubernetes 1.31.1 >=1.30.0-0 ► checking version in cluster ✔ distribution: flux-v2.4.0 ✔ bootstrapped: true ► checking controllers ✔ helm-controller: deployment ready ► ghcr.io/fluxcd/helm-controller:v1.1.0 ✔ image-automation-controller: deployment ready ► ghcr.io/fluxcd/image-automation-controller:v0.39.0 ✔ image-reflector-controller: deployment ready ► ghcr.io/fluxcd/image-reflector-controller:v0.33.0 ✔ kustomize-controller: deployment ready ► ghcr.io/fluxcd/kustomize-controller:v1.4.0 ✔ notification-controller: deployment ready ► ghcr.io/fluxcd/notification-controller:v1.4.0 ✔ source-controller: deployment ready ► ghcr.io/fluxcd/source-controller:v1.4.1 ► checking crds ✔ alerts.notification.toolkit.fluxcd.io/v1beta3 ✔ buckets.source.toolkit.fluxcd.io/v1 ✔ gitrepositories.source.toolkit.fluxcd.io/v1 ✔ helmcharts.source.toolkit.fluxcd.io/v1 ✔ helmreleases.helm.toolkit.fluxcd.io/v2 ✔ helmrepositories.source.toolkit.fluxcd.io/v1 ✔ imagepolicies.image.toolkit.fluxcd.io/v1beta2 ✔ imagerepositories.image.toolkit.fluxcd.io/v1beta2 ✔ imageupdateautomations.image.toolkit.fluxcd.io/v1beta2 ✔ kustomizations.kustomize.toolkit.fluxcd.io/v1 ✔ ocirepositories.source.toolkit.fluxcd.io/v1beta2 ✔ providers.notification.toolkit.fluxcd.io/v1beta3 ✔ receivers.notification.toolkit.fluxcd.io/v1 ✔ all checks passed
Git provider
No response
Container Registry provider
No response
Additional context
No response
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Maybe a duplicate of #5051
Maybe a duplicate of https://github.com/fluxcd/flux2/issues/5051
Not really, these are two separate bugs.
On this one, to me it seems like we should be returning errors here:
https://github.com/fluxcd/flux2/blob/73fff7404f76953c0a224d12ca0dd276b8d9be63/pkg/status/status.go#L93-L96
@attributeerror @h3nryc0ding Are either of you interested in fixing this bug?