Skip to content

Require Flux 2.9 for the deprecated-API check#44

Merged
stefanprodan merged 1 commit into
fluxcd:mainfrom
lyzetam:fix/check-deprecated-require-flux-min-version
Jul 10, 2026
Merged

Require Flux 2.9 for the deprecated-API check#44
stefanprodan merged 1 commit into
fluxcd:mainfrom
lyzetam:fix/check-deprecated-require-flux-min-version

Conversation

@lyzetam

@lyzetam lyzetam commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #42.

Per @stefanprodan's suggestion on the issue, this adds a minimum Flux CLI version gate to check-deprecated.sh so the deprecated-API check fails loudly on older clients instead of reporting a false "clean".

Problem

check-deprecated.sh runs flux migrate -f . --dry-run, but older Flux CLIs lack the migrate subcommand. The error is swallowed by || true and the version-arrow grep never matches, so the script prints No deprecated Flux API versions found and exits 0 — a false negative that reports the repo as clean when the check never ran.

Change

check_prerequisites() now parses the client version (flux version --client) and requires Flux >= 2.9.0 (the release that provides flux migrate), failing with an actionable upgrade message otherwise. Version comparison is a small pure-bash numeric helper — no sort -V/GNU dependency — so it stays portable across operator environments.

Testing

  • shellcheck skills/gitops-repo-audit/scripts/*.sh — clean
  • Flux 2.5.1 (real machine): now errors Flux CLI v2.5.1 is too old; 'flux migrate' requires Flux 2.9.0 or later (previously printed the false "No deprecated Flux API versions found")
  • Simulated 2.8.0: blocked; 2.9.0: passes the gate

@stefanprodan stefanprodan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One small nit

local version
version="$(flux version --client 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)"
if [[ -z "$version" ]]; then
echo "ERROR - unable to determine the Flux CLI version" >&2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is dead code! How can Opus be this bad at Bash? LOL

Fix to avoid an exit 1 with no message (due to set -o pipefail):

version="$(flux version --client 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true)"

check-deprecated.sh runs 'flux migrate --dry-run', but older Flux
CLIs lack the migrate subcommand. The error was swallowed by
'|| true' and the version-arrow grep never matched, so the script
printed "No deprecated Flux API versions found" and exited 0 — a
false negative reporting the repo as clean when the check never ran.

Add a minimum-version gate (Flux >= 2.9.0) to check_prerequisites so
the script fails with an actionable message instead.

Fixes fluxcd#42

Signed-off-by: Landry Zetam <[email protected]>
Assisted-by: Claude Code/claude-opus-4-8
@lyzetam
lyzetam force-pushed the fix/check-deprecated-require-flux-min-version branch from 34509fc to b37f10d Compare July 10, 2026 18:09
@lyzetam

lyzetam commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Good catch, thanks — you're right. Under set -o errexit + pipefail, the failing pipeline in the assignment trips errexit before the [[ -z "$version" ]] check runs, so that branch was dead and the script would exit 1 with no message. Applied your || true fix and verified the "unable to determine version" path now actually prints (and the too-old / pass paths still work). I also applied the same fix to the identical construct in #45.

@stefanprodan stefanprodan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@stefanprodan
stefanprodan merged commit ad12818 into fluxcd:main Jul 10, 2026
2 checks passed
@lyzetam

lyzetam commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@stefanprodan fix pushed and re-verified — ready for another look when you have a moment. Thanks for the catch!

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.

check-deprecated.sh reports "No deprecated Flux API versions found" when flux migrate is unavailable (false negative)

2 participants