Skip to content

Commit 926010a

Browse files
committed
fix(validator): require same-line nvidia-smi driver field labels
\s+ between driver|kmd and version: matched a newline, so a split label could parse as a banner version. Restrict to horizontal whitespace like the colon-side check. Signed-off-by: Rohit Rajani <rorajani@nvidia.com>
1 parent 5043853 commit 926010a

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

validators/deployment/nvidia_smi.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ const (
7070
// nvidiaSMIDriverVersionRE extracts the host driver / KMD version from an
7171
// nvidia-smi banner. Matches both legacy ("Driver Version:") and renamed
7272
// ("KMD Version:") fields, case-insensitively, including the table-row layout
73-
// where fields sit on one pipe-delimited line (issue #1667). After the colon,
74-
// only horizontal whitespace is allowed so a version on the next line is not
75-
// treated as the field's value. Caps at three numeric components — NVIDIA
76-
// driver versions are Major.Minor.Patch. Truncation of a longer version
73+
// where fields sit on one pipe-delimited line (issue #1667). Horizontal
74+
// whitespace only — both between the field words and after the colon — so a
75+
// split label ("Driver\nVersion:") or a version on the next line is not
76+
// treated as the field. Caps at three numeric components — NVIDIA driver
77+
// versions are Major.Minor.Patch. Truncation of a longer version
7778
// (e.g. "580.95.05.1") is rejected in parseNvidiaSMIDriverVersion: Go's RE2
7879
// engine has no negative lookahead.
7980
var nvidiaSMIDriverVersionRE = regexp.MustCompile(
80-
`(?i)(?:driver|kmd)\s+version:[ \t]*([0-9]+(?:\.[0-9]+){0,2})`)
81+
`(?i)(?:driver|kmd)[ \t]+version:[ \t]*([0-9]+(?:\.[0-9]+){0,2})`)
8182

8283
// gpuNodeCoverage partitions check-nvidia-smi's discovered GPU nodes into the
8384
// schedulable cohort actually validated and the cordoned cohort skipped. It

validators/deployment/nvidia_smi_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ func TestParseNvidiaSMIDriverVersion(t *testing.T) {
241241
logs: "Driver Version:\n580.95.05\n",
242242
wantErr: true,
243243
},
244+
{
245+
// \s+ would let "Driver\nVersion:" match as the field label.
246+
name: "rejects newline between field words",
247+
logs: "Driver\nVersion: 580.95.05\n",
248+
wantErr: true,
249+
},
244250
{
245251
name: "accepts table pipe immediately after version",
246252
logs: "| Driver Version: 580.95.05| CUDA Version: 12.8 |\n",

0 commit comments

Comments
 (0)