fix: match full RHEL and Rocky product names in OS normalization - #2788
fix: match full RHEL and Rocky product names in OS normalization#2788rugggger wants to merge 1 commit into
Conversation
NormalizeOSImageName matched the literal "RHEL", but Kubernetes reports osImage as "Red Hat Enterprise Linux 9.7 (Plow)", so every RHEL node normalized to "unknown-os" and its builder containers were named after it. Rocky had the same gap: "rocky\s*(\d+)" never matched "Rocky Linux 8.10". Widen both patterns and add a table test covering the spellings Kubernetes actually emits. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
How to use the Graphite Merge QueueAdd the label main-merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Claude finished @rugggger's task in 2m 44s —— View job Claude Code Review
SummaryThe fix is correct and well-scoped. Two things worth a look, both raised inline: 1. RHEL 7 still falls through (inline) — RHEL 7's 2. Test table nits (inline) — Upgrade note (not a defect, worth release-noting)On clusters with RHEL/Rocky nodes, the builder container name changes from Secondary effect of the same rename: Minor observations
No security or performance concerns — both regexes are compiled once at package init, and neither introduces backtracking risk (Go's RE2 is linear-time regardless). Note on verificationI could not execute |
| ubuntuRe = regexp.MustCompile(`(?i)ubuntu\s+(\d+)\.(\d+)`) | ||
| rhelRe = regexp.MustCompile(`(?i)rhel\s*(\d+)`) | ||
| rockyRe = regexp.MustCompile(`(?i)rocky\s*(\d+)`) | ||
| rhelRe = regexp.MustCompile(`(?i)(?:rhel|red\s+hat\s+enterprise\s+linux)\s*(\d+)`) |
There was a problem hiding this comment.
The same class of gap remains for RHEL 7, which reports PRETTY_NAME="Red Hat Enterprise Linux Server 7.9 (Maipo)" — the word Server sits between Linux and the version, so \s*(\d+) fails and the node still normalizes to unknown-os. ("Server" was dropped in RHEL 8+, which is why 8/9 work.)
Worth handling explicitly rather than with a permissive [^\d]*: RHEL CoreOS reports Red Hat Enterprise Linux CoreOS 414.92.202310170514-0, and a greedy skip would turn that into rhel414. Leaving CoreOS at unknown-os is the safer behavior.
| rhelRe = regexp.MustCompile(`(?i)(?:rhel|red\s+hat\s+enterprise\s+linux)\s*(\d+)`) | |
| rhelRe = regexp.MustCompile(`(?i)(?:rhel|red\s+hat\s+enterprise\s+linux(?:\s+server)?)\s*(\d+)`) |
If RHEL 7 is outside the supported matrix, feel free to skip — but then it'd be good to say so in the doc comment.
| tests := []struct { | ||
| name string | ||
| input string | ||
| want string | ||
| }{ | ||
| {"Ubuntu 22.04.5 LTS", "Ubuntu 22.04.5 LTS", "ubuntu-22-04"}, | ||
| {"Ubuntu 24.04.3 LTS", "Ubuntu 24.04.3 LTS", "ubuntu-24"}, | ||
| {"Ubuntu 24.04.4 LTS", "Ubuntu 24.04.4 LTS", "ubuntu-24"}, | ||
| {"RHEL 9.4", "RHEL 9.4", "rhel09"}, | ||
| {"Red Hat Enterprise Linux 9.7 (Plow)", "Red Hat Enterprise Linux 9.7 (Plow)", "rhel09"}, | ||
| {"Red Hat Enterprise Linux 8.10", "Red Hat Enterprise Linux 8.10", "rhel08"}, | ||
| {"Rocky Linux 8.10", "Rocky Linux 8.10", "rocky08"}, |
There was a problem hiding this comment.
name is character-for-character identical to input in all nine cases, so it's pure duplication — dropping the field and using t.Run(tt.input, ...) gives the same subtest names (empty string becomes #00-style, or keep a name only where it adds something).
Coverage gaps worth adding while the table is here:
"Rocky Linux 9.6 (Blue Onyx)"— the codename-suffixed spelling for Rocky, mirroring the(Plow)case you added for RHEL."RHEL 10.0"/"Red Hat Enterprise Linux 10.0"— the only case that exercises%02swith a two-digit major (rhel10, notrhel010)."RHEL9"with no space —\s*allows it, so it's worth pinning as intended rather than accidental.
Graphite Automations"Add anton/matt/sergey/kristina as reviwers on operator PRs" took an action on this PR • (09/02/26)3 reviewers were added to this PR based on Anton Bykov's automation. |

NormalizeOSImageName matched the literal "RHEL", but Kubernetes reports
osImage as "Red Hat Enterprise Linux 9.7 (Plow)", so every RHEL node
normalized to "unknown-os" and its builder containers were named after
it. Rocky had the same gap: "rocky\s*(\d+)" never matched "Rocky Linux
8.10". Widen both patterns and add a table test covering the spellings
Kubernetes actually emits.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com