fix(policy): Fix DCGM policy listener fanout and preserve policy thresholds#119
Merged
rvatkar merged 2 commits intoApr 29, 2026
Merged
Conversation
nccurry
reviewed
Apr 28, 2026
nccurry
requested changes
Apr 28, 2026
nccurry
left a comment
Collaborator
There was a problem hiding this comment.
Just one small thing, otherwise LGTM
nccurry
approved these changes
Apr 29, 2026
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.
Summary
Fix DCGM policy listener callback handling by replacing shared global callback channels with a per-subscriber dispatcher. This prevents listener fanout races, callback blocking, premature cleanup, and policy threshold
clobbering while keeping public listener API signatures unchanged.
Covers:
Changes
userDataregistration IDs.Listen*APIs by merging missing conditions instead of resetting the whole policy to defaults.DCGM_ST_INSUFFICIENT_SIZEandDCGM_ST_NOT_CONFIGURED; propagate other policy-read errors.dcgmPolicyUnregistersucceeds or DCGM reports no live registration can remain.PolicyViolationDropCount()for slow-consumer drop visibility.userData.Validation
go test ./pkg/dcgm -count=1go test -race ./pkg/dcgm -run "TestPolicyDispatcherDeliverDuringUnsubscribeRace|TestPolicyDispatcherRollbackSubscription|TestPolicyDispatcherClearRegistrationKeepsStateOnUnregisterFailure| TestPolicyDispatcherSlowConsumerDrop|TestConcurrentPolicySubscribers|TestPolicyListenerLifecycle" -count=1 -vgo test ./pkg/dcgm -run "TestPolicyErrors|TestSetPolicyAndWatchViolations|TestSetAndGetPolicy|TestSetAndGetMultiplePolicies" -count=1 -vgo build ./...go vet ./...dcgm-exporter L4 Smoke Test
Built
dcgm-exporterfrom/home/rvatkar/code/dcgm-exporter-devagainst the local fixedgo-dcgmbranch using a temporarygo.workreplace.Confirm exporter uses local
go-dcgm:Expected: module resolves to /home/rvatkar/code/community/go-dcgm.
Build exporter:
GOWORK=/tmp/dcgm-exporter-gowork/go.work make binary
Run exporter on L4 host with reduced L4 counters:
/tmp/dcgm-exporter-after
-f /tmp/dcgm-exporter-l4-counters.csv
-a :9401
--enable-dcgm-log
--dcgm-log-level DEBUG
Scrape metrics:
curl -sf http://127.0.0.1:9401/metrics >/tmp/dcgm-exporter-after.metrics
grep -E "DCGM_FI_DEV_GPU_UTIL|DCGM_FI_DEV_SM_CLOCK|DCGM_FI_DEV_FB_USED|DCGM_FI_DEV_XID_ERRORS"
/tmp/dcgm-exporter-after.metrics
Repeated scrape soak:
for i in $(seq 1 30); do
curl -sf http://127.0.0.1:9401/metrics >/tmp/dcgm-exporter-after-$i.metrics || exit 1
sleep 10
done
Result:
Notes
No dcgm-exporter code change is required, but downstream consumers need to update github.com/NVIDIA/go-dcgm dependency to pick up this fix.