k3s: guard version test against non-semver manager_version#2892
Merged
Conversation
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>
jklare
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
a46cdd84introducedmanager_version is version('9.0.0', '<')in thekube_vip_bgp_peerstemplate without guarding against non-semver version strings9.5.0), the inventory reconciler overridesmanager_versionto the actual container image tag (e.g.v0.20260322.0)v0.20260322.0into['v', 20260322, 0]; comparing'v' < 9raises a Python TypeError, manifesting as"Version comparison failed: '<' not supported between instances of 'str' and 'int'"ink3s_serverargspec validationmanager_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.04testbed-upgrade-stable-next-ubuntu-24.04testbed-upgrade-stable-ubuntu-24.04Test plan
latestdeployments unaffected:manager_version != 'latest'still short-circuits before the version test🤖 Generated with Claude Code