Skip to content

fix(provider/dra): match nodes by annotated instance ID#405

Merged
dmitsh merged 1 commit into
mainfrom
ds-dra
Jul 22, 2026
Merged

fix(provider/dra): match nodes by annotated instance ID#405
dmitsh merged 1 commit into
mainfrom
ds-dra

Conversation

@dmitsh

@dmitsh dmitsh commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@dmitsh
dmitsh requested a review from ravisoundar as a code owner July 16, 2026 12:29
@dmitsh
dmitsh requested a review from bugra-gedik-nv July 16, 2026 12:29
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the DRA provider's node-matching logic to read the cloud instance ID from the topograph.nvidia.com/instance annotation rather than assuming the Kubernetes node name is the instance ID, bringing it in line with all other providers. The client field is also widened from *kubernetes.Clientset to kubernetes.Interface to enable unit testing with fakes.

  • GenerateTopologyConfig now looks up node.Annotations[topology.KeyNodeInstance] and skips (with a warning) any node missing or empty that annotation, then uses the annotation value as the key into the instances map instead of node.Name.
  • A new integration-style test (TestGenerateTopologyConfigUsesAnnotatedInstanceID) exercises the fix with a fake clientset, a node whose name differs from its annotated instance ID, and asserts the correct domain-map entry is produced.

Confidence Score: 5/5

Safe to merge — the fix is narrow, well-tested for the happy path, and consistent with how every other provider in the codebase already resolves instance IDs.

The change replaces a single hardcoded assumption (node.Name == instance ID) with the annotation-based lookup already used by every other provider. The new test confirms the corrected behavior with a fake clientset.

No files require special attention.

Important Files Changed

Filename Overview
pkg/providers/dra/provider.go Core fix: reads instance ID from annotation instead of node.Name; also widens client field to kubernetes.Interface for testability; error message now mentions KeyNodeInstance.
pkg/providers/dra/provider_test.go Adds a unit test for the annotation-based lookup with a fake clientset; happy path is covered, but the new warning/skip branch for missing or empty annotations has no test coverage.
CHANGELOG.md Adds a changelog entry accurately describing the fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[GenerateTopologyConfig called] --> B[List Kubernetes nodes]
    B --> C{Node has DomainLabel?}
    C -- No --> D[Skip node]
    C -- Yes --> E{Node has KeyNodeRegion annotation?}
    E -- No / unmatched region --> D
    E -- Yes --> F{Node has KeyNodeInstance annotation?}
    F -- Missing or empty --> G[klog.Warningf + skip node]
    F -- Present --> H{instanceID in instances map?}
    H -- No --> D
    H -- Yes --> I[domainMap.AddHost clusterID, instanceID, host]
    I --> J{Any hosts added?}
    J -- No --> K[Return 502 error]
    J -- Yes --> L[Return topology.Graph]
Loading

Reviews (6): Last reviewed commit: "fix(provider/dra): match nodes by annota..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.59%. Comparing base (8468abe) to head (ed84e66).
⚠️ Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
pkg/providers/dra/provider.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #405      +/-   ##
==========================================
+ Coverage   72.15%   73.59%   +1.44%     
==========================================
  Files          89       94       +5     
  Lines        5689     6272     +583     
==========================================
+ Hits         4105     4616     +511     
- Misses       1382     1410      +28     
- Partials      202      246      +44     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dmitsh
dmitsh force-pushed the ds-dra branch 2 times, most recently from 36ef80a to 23561d5 Compare July 19, 2026 08:13
@github-actions

Copy link
Copy Markdown
Contributor

@ArangoGutierrez ArangoGutierrez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correct fix — DRA was the last provider still joining on node.Name, and the new test genuinely discriminates it (node name differs from the instance ID). One optional diagnostic suggestion below.

  1. A clique-labeled node missing this annotation is now skipped silently. The sibling join sites warn on the same skip — internal/k8s/utils.go and engines/slinky/engine.go both do klog.Warningf("missing %q annotation in node %s", ...), and #379 added exactly this diagnostic to the structurally identical clique+annotation loop in Slinky. A klog.Warningf before the continue would restore that signal; otherwise a not-yet-annotated node disappears with no trace, since the BadGateway error only fires when every node is skipped. (pkg/providers/dra/provider.go:113)

Comment thread pkg/providers/dra/provider.go
Signed-off-by: Dmitry Shmulevich <dshmulevich@nvidia.com>
@dmitsh
dmitsh merged commit 7607854 into main Jul 22, 2026
7 checks passed
@dmitsh
dmitsh deleted the ds-dra branch July 22, 2026 17:17
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.

2 participants