Skip to content

Trim leading and trailing punctuation from sanitised GFD label values - #2173

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/sanitise-trim-punctuation
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/sanitise-trim-punctuation

Conversation

@0z5a

@0z5a 0z5a commented Nov 17, 2026 •

Copy link
Copy Markdown

Issue

Fixes #2172

Description

sanitise() in internal/lm/resource.go turns the DMI product name into the nvidia.com/gpu.machine label value (and is also used for the *.product values). It removes invalid characters and joins words with -, but it keeps a leading or trailing -, . or _. Kubernetes label values must start and end with an alphanumeric character, so product names such as ThinkSystem SR650 -[7X06CTO1WW]- (first-generation Lenovo ThinkSystem servers) and To Be Filled By O.E.M. (common AMI BIOS default) produce ThinkSystem-SR650--7X06CTO1WW- and To-Be-Filled-By-O.E.M., which NFD rejects, leaving the node without an nvidia.com/gpu.machine label.

This change trims -, _ and . from both ends of the sanitised value. Values that were already valid are unchanged. The 63-character limit for product labels (#1876) is out of scope.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Lint checks passing (make lint)
  • Unit tests passing (make test)
  • Go mod artifacts in-sync (make check-modules)
  • Third-party notices in-sync (make check-third-party-notices)
  • Test cases are added for new code paths

Testing

  • Added the two product names and an all-punctuation case to TestSanitise.
  • Added TestMachineTypeLabeler, which writes a product name to a temp file, builds the labeler with newMachineTypeLabeler and checks the value with k8s.io/apimachinery/pkg/util/validation.IsValidLabelValue (PowerEdge XE9680 is the control case).
  • go test ./internal/lm/ -run 'TestSanitise|TestMachineTypeLabeler': fails on main (3 TestSanitise cases, 2 TestMachineTypeLabeler cases), passes with this change.
  • go test ./internal/... ./api/... ./cmd/gpu-feature-discovery/... passes.

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.


Devin Review

sanitise() kept a leading or trailing '-', '.' or '_', so DMI product
names such as "ThinkSystem SR650 -[7X06CTO1WW]-" and
"To Be Filled By O.E.M." produced nvidia.com/gpu.machine values that
are not valid Kubernetes label values and are dropped by NFD.

Trim those characters after joining the words. Values that were
already valid are unchanged.

Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
@copy-pr-bot

copy-pr-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GFD emits an invalid nvidia.com/gpu.machine label value when the DMI product name ends (or starts) with '-', '.' or '_'

1 participant