flux2 icon indicating copy to clipboard operation
flux2 copied to clipboard

`flux check` always returns 0

Open attributeerror opened this issue 10 months ago • 2 comments

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:

Image

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

  1. Install Flux.
  2. Create a ServiceAccount missing some permissions required for flux check to run (reference https://github.com/fluxcd/flux2/discussions/5217#discussioncomment-12344858).
  3. Run flux check.
  4. 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

attributeerror avatar Feb 27 '25 22:02 attributeerror

Maybe a duplicate of #5051

henrichter avatar Mar 13 '25 17:03 henrichter

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?

matheuscscp avatar Mar 14 '25 12:03 matheuscscp