Skip to content

fix(worker): populate metering nspect_id from NVCF_NSPECT_ID env#285

Merged
kristinapathak merged 1 commit into
NVIDIA:mainfrom
shobham-nv:shobham/fix/worker-metering-nspect-id
Jul 21, 2026
Merged

fix(worker): populate metering nspect_id from NVCF_NSPECT_ID env#285
kristinapathak merged 1 commit into
NVIDIA:mainfrom
shobham-nv:shobham/fix/worker-metering-nspect-id

Conversation

@shobham-nv

@shobham-nv shobham-nv commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

NVCF worker metering events (NVCF_Invocation and NVCF_Infrastructure) were being emitted with an empty data.nspect_id, causing the downstream metering ingestion pipeline to reject them for failing mandatory-field schema validation.

During the open-source split, nspect_id was moved to the NVCF_NSPECT_ID env var, but the worker only consumed it for the NVCF-NSPECTID inference header and never populated metering.Config.NspectId (serialized in metering.go and infra.go). This wires metering.NspectIdFromEnv() into the metering config so the events carry the nspect_id again.

Changes

  • Set NspectId: metering.NspectIdFromEnv() in the three metering.Config constructors:
    • src/compute-plane-services/worker-utils/worker/worker.go (function worker — emits both affected event types)
    • src/compute-plane-services/worker-init/internal/workerinit/initializer.go (init-phase infra events)
    • src/compute-plane-services/worker-task/internal/worker/worker.go (task infra events)
  • Added a unit test asserting NVCF_NSPECT_ID flows into meteringConfig.NspectId.

Testing

  • gofmt clean.
  • New test TestNewNVCFWorker_Normalization/"nspect id is populated from environment for metering events".
  • Existing metering tests already assert nspect_id serialization from Config.NspectId.

Issues

NO-REF

Summary by CodeRabbit

  • New Features

    • Metering configuration now captures the spectral identifier provided through the environment across worker initialization and creation paths.
  • Tests

    • Added coverage confirming the environment-provided spectral identifier is correctly propagated into worker metering configuration.

@shobham-nv
shobham-nv requested a review from a team as a code owner July 21, 2026 05:56
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 40c13a1c-079b-4b6a-97e3-963af0a31070

📥 Commits

Reviewing files that changed from the base of the PR and between 722d784 and 7b873bb.

📒 Files selected for processing (6)
  • src/compute-plane-services/worker-init/internal/workerinit/initializer.go
  • src/compute-plane-services/worker-init/internal/workerinit/initializer_test.go
  • src/compute-plane-services/worker-task/internal/worker/worker.go
  • src/compute-plane-services/worker-task/internal/worker/worker_newnvctworker_test.go
  • src/compute-plane-services/worker-utils/worker/newworker_test.go
  • src/compute-plane-services/worker-utils/worker/worker.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/compute-plane-services/worker-init/internal/workerinit/initializer.go
  • src/compute-plane-services/worker-utils/worker/worker.go
  • src/compute-plane-services/worker-task/internal/worker/worker.go
  • src/compute-plane-services/worker-utils/worker/newworker_test.go

📝 Walkthrough

Walkthrough

Initializer and worker metering configurations now populate NspectId from the environment. Tests cover initializer, task-worker, and NVCF-worker propagation.

Changes

Nspect ID metering propagation

Layer / File(s) Summary
Populate and verify environment-derived Nspect IDs
src/compute-plane-services/worker-init/..., src/compute-plane-services/worker-task/..., src/compute-plane-services/worker-utils/worker/*
Initializer and worker metering configurations assign NspectId using metering.NspectIdFromEnv(). Tests verify propagation across all three construction paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: kristinapathak

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: populating metering nspect_id from NVCF_NSPECT_ID.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/compute-plane-services/worker-init/internal/workerinit/initializer.go`:
- Line 146: The constructors lack coverage for propagating their newly added
values. Add a test for NewInitializer in
src/compute-plane-services/worker-init/internal/workerinit/initializer.go:146-146
that verifies NspectId propagation, and a test for NewNVCTWorker in
src/compute-plane-services/worker-task/internal/worker/worker.go:128-128 that
verifies task propagation; otherwise document the omission in the PR
description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4dafe444-1f35-4b91-8a9c-632c94a9f974

📥 Commits

Reviewing files that changed from the base of the PR and between 41543b2 and 722d784.

📒 Files selected for processing (4)
  • src/compute-plane-services/worker-init/internal/workerinit/initializer.go
  • src/compute-plane-services/worker-task/internal/worker/worker.go
  • src/compute-plane-services/worker-utils/worker/newworker_test.go
  • src/compute-plane-services/worker-utils/worker/worker.go

Metering events (NVCF_Invocation and NVCF_Infrastructure) were emitted
with an empty data.nspect_id, causing UAM ingestion to reject them for
failing schema validation. During the OSS split nspect_id moved to the
NVCF_NSPECT_ID env var, but the worker only consumed it for the
NVCF-NSPECTID inference header and never populated metering.Config.NspectId.

Wire metering.NspectIdFromEnv() into the metering.Config built by the
function worker, worker-init initializer, and task worker so metering
events carry the nspect_id again.

Signed-off-by: shobham <shobham@nvidia.com>
@shobham-nv
shobham-nv force-pushed the shobham/fix/worker-metering-nspect-id branch from 722d784 to 7b873bb Compare July 21, 2026 16:36
@kristinapathak
kristinapathak enabled auto-merge July 21, 2026 16:42
@kristinapathak
kristinapathak added this pull request to the merge queue Jul 21, 2026
Merged via the queue into NVIDIA:main with commit d7c934c Jul 21, 2026
16 checks passed
@balajinvda

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version nvcf-worker-init-v1.0.8 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@balajinvda

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version nvcf-worker-utils-v1.0.7 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@balajinvda

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version nvcf-worker-task-v1.0.7 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants