Skip to content

k3s: guard version test against non-semver manager_version#2892

Merged
jklare merged 1 commit into
mainfrom
fix/k3s-non-semver-manager-version
May 20, 2026
Merged

k3s: guard version test against non-semver manager_version#2892
jklare merged 1 commit into
mainfrom
fix/k3s-non-semver-manager-version

Conversation

@ideaship
Copy link
Copy Markdown
Contributor

Summary

  • Commit a46cdd84 introduced manager_version is version('9.0.0', '<') in the kube_vip_bgp_peers template without guarding against non-semver version strings
  • For upgrade/update jobs that start from a semver manager version (e.g. 9.5.0), the inventory reconciler overrides manager_version to the actual container image tag (e.g. v0.20260322.0)
  • LooseVersion splits v0.20260322.0 into ['v', 20260322, 0]; comparing 'v' < 9 raises a Python TypeError, manifesting as "Version comparison failed: '<' not supported between instances of 'str' and 'int'" in k3s_server argspec validation
  • Adds manager_version is match('^[0-9]') guard so non-digit-starting strings (date-based container tags) short-circuit to the else branch (correct 9.x+ behaviour)

Impact

Fixes three midnight CI failures on osism/testbed (2026-05-20):

  • testbed-update-stable-current-ubuntu-24.04
  • testbed-upgrade-stable-next-ubuntu-24.04
  • testbed-upgrade-stable-ubuntu-24.04

Test plan

  • CI midnight run after merge should show these three jobs passing the k3s deploy step
  • latest deployments unaffected: manager_version != 'latest' still short-circuits before the version test

🤖 Generated with Claude Code

Deploying with --version-manager 9.5.0 fails at the k3s_server
argument spec validation step with:

  Version comparison failed: '<' not supported between instances
  of 'str' and 'int'

The Jinja2 template for kube_vip_bgp_peers (added in 2b41f741)
evaluates manager_version is version('9.0.0', '<') to decide
whether to pass an empty peer list (8.x old bgppeers format) or
the full list (9.x bgp_peers format).

The bug: in 9.x deployments the inventory reconciler sets
manager_version to the actual container image tag, e.g.
v0.20251130.0, rather than the OSISM release semver (9.5.0).
When Ansible's LooseVersion comparison splits this string it
produces a mixed-type tuple ['v', 20251130, 0]; comparing the
leading 'v' component against the integer 9 from LooseVersion
('9.0.0') raises a Python TypeError.

In 8.x deployments the reconciler uses the OSISM release semver
(e.g. 8.1.0) as manager_version, so the comparison worked there.
For 'latest' deployments the existing manager_version \!= 'latest'
guard short-circuits before the version test.

Fix by adding manager_version is match('^[0-9]') before the
version() call. This ensures the comparison is only attempted for
plain semver strings beginning with a digit; date-based container
tags (v0.YYYYMMDD.N) and any other non-numeric values short-circuit
to the else branch, which is the correct 9.x+ behaviour.

AI-assisted: Claude Code
Signed-off-by: Roger Luethi <luethi@osism.tech>
@ideaship ideaship requested a review from jklare May 20, 2026 05:19
@ideaship ideaship marked this pull request as ready for review May 20, 2026 05:19
@ideaship ideaship moved this from Ready to In review in Human Board May 20, 2026
@jklare jklare merged commit 89e9061 into main May 20, 2026
3 checks passed
@jklare jklare deleted the fix/k3s-non-semver-manager-version branch May 20, 2026 06:11
@github-project-automation github-project-automation Bot moved this from In review to Done in Human Board May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants