File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
7980var 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
Original file line number Diff line number Diff line change @@ -241,6 +241,12 @@ func TestParseNvidiaSMIDriverVersion(t *testing.T) {
241241 logs : "Driver Version:\n 580.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\n Version: 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 " ,
You can’t perform that action at this time.
0 commit comments