feat: Support K8s DRA Resources V1 APIs#596
Open
adityasingh0510 wants to merge 1 commit intoNVIDIA:mainfrom
Open
feat: Support K8s DRA Resources V1 APIs#596adityasingh0510 wants to merge 1 commit intoNVIDIA:mainfrom
adityasingh0510 wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
c179153 to
2d09218
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates dcgm-exporter to support both the stable
resource.k8s.io/v1API and thev1beta1API for Dynamic Resource Allocation (DRA) support. This ensures compatibility with both Kubernetes 1.34+ clusters (using v1) and older clusters (using v1beta1), with automatic detection and graceful fallback.Problem
When enabling DRA labels in dcgm-exporter on Kubernetes 1.34+ clusters, the following error occurs:
This happens because:
Changes
Files Modified
internal/pkg/transformation/dra.go:onAddOrUpdateV1()/onAddOrUpdateV1beta1()onDeleteV1()/onDeleteV1beta1()dev.Basic.Attributesdev.Attributes(direct access, no Basic wrapper)internal/pkg/transformation/types.go:v1Informerandv1beta1Informerfields toDRAResourceSliceManagerstructgo.mod/go.sum:k8s.io/api: v0.33.3 → v0.34.0 (adds support forresource/v1)k8s.io/client-go: v0.33.3 → v0.34.0 (ensures compatibility)k8s.io/apimachinery: v0.33.3 → v0.34.0API Structure Changes
The v1 API has a different structure than v1beta1:
dev.Basic.Attributesdev.Attributes(direct)The implementation handles both structures correctly.
Behavior
Automatic API Detection
The code registers both informers and uses whichever is available:
Precedence Logic
When both APIs are available:
Testing
Verification
Code compiles successfully with both API versions
All tests pass - existing unit tests continue to work
No linter errors
v1 API support - verified with Kubernetes 1.34+ API structure
v1beta1 API support - verified with Kubernetes 1.27-1.33 API structure
Dual API handling - both informers work correctly when both are available
Precedence logic - v1 correctly takes precedence over v1beta1
Delete handling - race conditions prevented with cache checking
Test Scenarios
Backward Compatibility
Fully backward compatible:
Forward compatible:
Breaking Changes
None - This is a backward and forward compatibility enhancement. The change:
Related Issues