Skip to content

Allow set extra labels/annotations - #2791

Open
andriishestakov wants to merge 3 commits into
nebius:mainfrom
andriishestakov:add-labels
Open

andriishestakov wants to merge 3 commits into
nebius:mainfrom
andriishestakov:add-labels

Conversation

@andriishestakov

Copy link
Copy Markdown
Contributor

Problem

Solution

Testing

Release Notes

Comment thread internal/render/exporter/pod.go Outdated
nodeFilter = slurmv1.K8sNodeFilter{}
}
labels := maps.Clone(matchLabels)
maps.Copy(labels, clusterValues.SlurmExporter.Labels)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

User labels can hijack selector labels and permanently wedge the StatefulSet. Every render does maps.Copy(labels, X.Labels) after building the operator's labels, so user keys win - but the selector is built separately from matchLabels, which is not updated. Setting extraLabels: {app.kubernetes.io/component: foo} (or name/instance, or slurm.nebius.ai/nodeset) makes the pod template diverge from the immutable selector.

Comment thread api/v1/slurmcluster_types.go Outdated
// +kubebuilder:validation:Required
SlurmNodes SlurmNodes `json:"slurmNodes"`

// ExtraLabels are custom K8s labels added to every Pod and the spool PVC of this cluster.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The spool PVC doc comment doesn't match the behavior. Both CRD fields say "added to every Pod and the spool PVC of this cluster", but nothing in the operator labels a PVC: common/volume.go:46-60 (the VolumeClaimTemplates, including the worker spool) is untouched. The only PVC labeling is chart-side in pvc.yaml, which iterates .Values.volumeSources with createPVC — jail and friends, not spool, and driven by chart values rather than the CR field. If the use case is billing attribution, unlabeled operator-created PVCs are probably the most valuable remaining gap; either way the comment should be corrected.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ActiveCheck can use spool PVC. It needs to be rewritten.

@asteny

asteny commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@andriishestakov Hi!

The selector-label collision and PVC coverage from the previous review are now addressed in the rendering layer. There are still several reconciliation issues to resolve before this can be merged:

  1. Existing Deployment-backed components will not receive new labels or annotations. DeploymentReconciler.patch copies only Spec.Template.Spec and does not copy Spec.Template.ObjectMeta. This affects accounting, REST, exporter, and sconfigcontroller.

  2. Existing ActiveCheck CronJobs will not receive the metadata either. CronJobReconciler.patch copies only the pod spec and ignores CronJob labels, JobTemplate metadata, and PodTemplate metadata.

  3. Existing MariaDB resources will not receive PodMetadata changes because MariaDbReconciler.patch does not reconcile Spec.PodTemplate.

  4. extraAnnotations can overwrite the operator-owned slurm.nebius.ai/activecheck annotation. The ActiveCheck controller relies on this annotation to associate pods with checks. Operator-owned annotation keys must take precedence, similarly to protected labels.

  5. Removing an extra annotation does not remove it from StatefulSet pod templates. Both StatefulSet reconcilers only copy desired keys into the existing map, so deleted custom annotations remain indefinitely. Please define and implement proper ownership/removal semantics.

Please add reconciliation tests that create an existing resource, update extraLabels/extraAnnotations, reconcile it, and verify that additions, changes, removals, and protected-key collisions behave correctly. Renderer-only tests do not cover these issues.

The PR also currently conflicts with main and its Problem/Solution/Testing/Release Notes sections are empty. Please resolve the conflicts and complete the description before merge.

Thanks!

This branch is waiting to be deployed

1 waiting deployment
fork-ci — 632fb486 Waiting Sep 23, 2026 by andriishestakov via Authorize #8225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature helm Functional changes in Helm charts

3 participants