Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package mscontroller
import (
"context"
"fmt"
"maps"

"github.com/NVIDIA/nvcf/src/libraries/go/lib/pkg/icms-translate/translate/common"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -88,10 +89,20 @@ func (r *Reconciler) buildMiniserviceMetadata(
ModelCacheInitEnv: in.ModelCacheInitEnv,
}

meta.Labels, meta.Annotations = newGeneralObjectLabelsAndAnnotations(
labels, annotations := newGeneralObjectLabelsAndAnnotations(
r.FeatureFlagFetcher, ms, icmsReq,
r.ClusterRegion, r.ClusterName, in.FunctionName, in.TaskName, false,
)
if meta.Labels == nil {
meta.Labels = labels
} else {
maps.Copy(meta.Labels, labels)
}
if meta.Annotations == nil {
meta.Annotations = annotations
} else {
maps.Copy(meta.Annotations, annotations)
}
Comment on lines +92 to +105

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add regression coverage for the merge contract.

The supplied metadata_configmap_test.go round-trip test does not verify that unrelated labels and annotations survive the merge. It also does not define duplicate-key precedence. Add cases for preserved entries, nil input maps, and the intended collision behavior. The current code gives generated values precedence for duplicate keys. (pkg.go.dev)

If tests are intentionally omitted, explain the omission in the Pull Request description.

As per coding guidelines, code changes must include tests; if tests are omitted, explain why in the Pull Request description.

🤖 Prompt for 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.

In `@src/compute-plane-services/nvca/internal/miniservice/metadata_configmap.go`
around lines 92 - 105, Extend the regression coverage for the metadata merge
logic around newGeneralObjectLabelsAndAnnotations and the metadata_configmap
round-trip test: verify unrelated labels and annotations are preserved, nil
input maps are handled, and duplicate keys retain the generated values currently
established by maps.Copy. Add focused cases for both labels and annotations
without changing the merge implementation.

Source: Coding guidelines


if r.FeatureFlagFetcher.IsFeatureFlagEnabled(featureflag.KAIScheduler) {
meta.SchedulerName = kaischeduler.SchedulerName
Expand Down
Loading