Skip to content

Commit 5043853

Browse files
committed
fix(validator): tighten nvidia-smi driver version parsing
Require the version on the same banner line (horizontal whitespace only), wrap log-verification errors with the node name, and add a numeric-order floor case so lexical string compare cannot silently pass the tests. Signed-off-by: Rohit Rajani <rorajani@nvidia.com>
1 parent f8408e7 commit 5043853

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

validators/deployment/nvidia_smi.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ 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). Caps at three
74-
// numeric components — NVIDIA driver versions are Major.Minor.Patch. Truncation
75-
// of a longer version (e.g. "580.95.05.1") is rejected in
76-
// parseNvidiaSMIDriverVersion: Go's RE2 engine has no negative lookahead.
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
77+
// (e.g. "580.95.05.1") is rejected in parseNvidiaSMIDriverVersion: Go's RE2
78+
// engine has no negative lookahead.
7779
var nvidiaSMIDriverVersionRE = regexp.MustCompile(
78-
`(?i)(?:driver|kmd)\s+version:\s*([0-9]+(?:\.[0-9]+){0,2})`)
80+
`(?i)(?:driver|kmd)\s+version:[ \t]*([0-9]+(?:\.[0-9]+){0,2})`)
7981

8082
// gpuNodeCoverage partitions check-nvidia-smi's discovered GPU nodes into the
8183
// schedulable cohort actually validated and the cordoned cohort skipped. It
@@ -367,7 +369,8 @@ func verifySingleGPUNode(ctx *validators.Context, nodeName string) error {
367369
}
368370

369371
if err := verifyNvidiaSMILogs(podLogs, createdPod); err != nil {
370-
return err
372+
return errors.Wrap(errors.ErrCodeInternal,
373+
fmt.Sprintf("nvidia-smi log verification failed on node %s", nodeName), err)
371374
}
372375
return enforceGPUDriverVersionFloor(ctx, podLogs, nodeName)
373376
}

validators/deployment/nvidia_smi_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ func TestParseNvidiaSMIDriverVersion(t *testing.T) {
236236
logs: "Driver Version: 580.95.05-rc1\n",
237237
wantErr: true,
238238
},
239+
{
240+
name: "rejects version on the next line after the field",
241+
logs: "Driver Version:\n580.95.05\n",
242+
wantErr: true,
243+
},
239244
{
240245
name: "accepts table pipe immediately after version",
241246
logs: "| Driver Version: 580.95.05| CUDA Version: 12.8 |\n",
@@ -293,6 +298,13 @@ func TestEnforceGPUDriverVersionFloor(t *testing.T) {
293298
constraint: ">= 580.95.05",
294299
logs: goodLogs,
295300
},
301+
{
302+
// Lexical string compare would fail here ('.100' < '.99'); the
303+
// constraint evaluator must compare components numerically.
304+
name: "numeric order beats lexical order",
305+
constraint: ">= 580.99.99",
306+
logs: "NVIDIA-SMI\nDriver Version: 580.100.0\nCUDA Version: 12.8\n" + gpuCheckSuccessMsg,
307+
},
296308
{
297309
name: "below floor fails",
298310
constraint: ">= 580.95.05",

0 commit comments

Comments
 (0)