feat: add affinity and nodeSelector to common daemonset config - #2645
feat: add affinity and nodeSelector to common daemonset config#2645amarkdotdev wants to merge 5 commits into
Conversation
f0aa669 to
530835d
Compare
530835d to
be752b6
Compare
|
Hey, this is waiting on CI workflow approval / first-time contributor vetting. Could a maintainer kick that off when convenient? Thanks! |
|
/ok-to-test be752b6 |
be752b6 to
9efb8b7
Compare
|
@rajathagasthya Fixed the generated GPUCluster CRDs and rebased the branch onto upstream/main. |
|
Thanks @amarkdotdev! We are in a bit of a code freeze right now for an upcoming release, so we're only taking release-critical PRs. You can expect this PR to get attention once the release is done. |
|
@rajathagasthya ok no problem:) |
Expose spec.daemonsets.affinity and spec.daemonsets.nodeSelector on ClusterPolicy and wire them through Helm. User nodeSelector labels are merged with existing operand nodeSelector entries. Use a schemaless CRD field for affinity so we do not embed the full corev1.Affinity OpenAPI schema in the ClusterPolicy CRD. Signed-off-by: amarkdotdev <amarkdotdev@users.noreply.github.com> # Conflicts: # controllers/transforms_test.go Signed-off-by: Aaron <amark@g.jct.ac.il> Signed-off-by: Aaron <amark@g.jct.ac.il>
Regenerate published GPUCluster CRDs for the common daemonset affinity and nodeSelector API fields. Signed-off-by: amarkdotdev <amarkdotdev@users.noreply.github.com> Signed-off-by: Aaron <amark@g.jct.ac.il>
9efb8b7 to
aebd56c
Compare
📝 WalkthroughWalkthrough
Merge Risk: 🟡 Moderate · up to User-provided nodeSelector values can currently overwrite protected GPU Operator selectors, potentially placing daemonset operands on unsuitable nodes or preventing expected GPU/NFD targeting. Merge should wait until those protected selectors remain authoritative. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Enterprise
Run ID: 29c358f5-21e9-441c-8a35-005c6985e51e
⛔ Files ignored due to path filters (7)
api/nvidia/v1/zz_generated.deepcopy.gois excluded by!**/zz_generated.*.gobundle/manifests/nvidia.com_clusterpolicies.yamlis excluded by!bundle/manifests/nvidia.com_*.yamlbundle/manifests/nvidia.com_gpuclusters.yamlis excluded by!bundle/manifests/nvidia.com_*.yamlconfig/crd/bases/nvidia.com_clusterpolicies.yamlis excluded by!config/crd/bases/**config/crd/bases/nvidia.com_gpuclusters.yamlis excluded by!config/crd/bases/**deployments/gpu-operator/crds/nvidia.com_clusterpolicies.yamlis excluded by!deployments/gpu-operator/crds/**deployments/gpu-operator/crds/nvidia.com_gpuclusters.yamlis excluded by!deployments/gpu-operator/crds/**
📒 Files selected for processing (5)
api/nvidia/v1/clusterpolicy_types.gocontrollers/object_controls.gocontrollers/transforms_test.godeployments/gpu-operator/templates/clusterpolicy.yamldeployments/gpu-operator/values.yaml
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.
|
rebased |
Signed-off-by: Aaron <amark@g.jct.ac.il>
kvalliyurnatt
left a comment
There was a problem hiding this comment.
@amarkdotdev Thanks for your contribution. Left a few comments
| }, | ||
| }, | ||
| }, | ||
| }) |
There was a problem hiding this comment.
I think there is a comma missing here
| }) | |
| }), |
| obj.Spec.Template.Spec.NodeSelector = make(map[string]string) | ||
| } | ||
| for key, value := range config.Daemonsets.NodeSelector { | ||
| if strings.HasPrefix(key, "nvidia.com/gpu.deploy.") { |
There was a problem hiding this comment.
I think we still have a few more selectors we want to protect. For example nvidia.com/mps.capable: "true" if overriden can end up placing MPS control daemon on unsuitable nodes. I think we should make sure we protect all operand selectors here. I think we don't want to overwrite any existing NodeSelectors probably right ? maybe we need to keep the user sent node selectors to strictly be additive
There was a problem hiding this comment.
nodeSelector is additive now, existing operand keys stay put
| } | ||
|
|
||
| if config.Daemonsets.Affinity != nil { | ||
| obj.Spec.Template.Spec.Affinity = config.Daemonsets.Affinity |
There was a problem hiding this comment.
This also removes any existing affinity, I think affinity should be merged with existing operand defined affinity here.
There was a problem hiding this comment.
affinity merges with the operand now instead of replacing it
| affinity: | ||
| description: 'Optional: Set affinity for all Daemonsets' | ||
| type: object | ||
| x-kubernetes-preserve-unknown-fields: true |
There was a problem hiding this comment.
I understand we want affinity to be schema less to prevent pulling in the entire affinity definition, but the way we have it now makes validation difficult, would it be so bad to inline the openAPI spec ?
There was a problem hiding this comment.
kept it schemaless for now to avoid dragging the full affinity openapi into the crd bundle
Only add nodeSelector keys that are not already set on the operand and merge cluster policy affinity with existing daemonset affinity. Signed-off-by: Aaron <amark@g.jct.ac.il>
| if merged.RequiredDuringSchedulingIgnoredDuringExecution == nil { | ||
| merged.RequiredDuringSchedulingIgnoredDuringExecution = src.RequiredDuringSchedulingIgnoredDuringExecution.DeepCopy() | ||
| } else { | ||
| merged.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append( |
There was a problem hiding this comment.
NodeSelectorTerms are ORed by Kubernetes, so appending the source terms changes the result to existing OR user, which broadens scheduling, I think we want existing AND user to be additive in this case. We would need to do a cartesian product I believe of the existing terms with the new terms to make it additive.
There was a problem hiding this comment.
cartesian product on the selector terms now
NodeSelectorTerms are ORed by Kubernetes. Merge existing operand terms with user terms via cartesian product so constraints are additive instead of broadening scheduling. Signed-off-by: Aaron <amark@g.jct.ac.il>
Fixes #2626
ClusterPolicy already exposes common tolerations for operand daemonsets but there was no matching knob for affinity or nodeSelector. This adds both under
spec.daemonsetsand surfaces them in Helm asdaemonsets.affinityanddaemonsets.nodeSelector.User nodeSelector labels are merged into the operand nodeSelector, so the existing
nvidia.com/gpu.deploy.*labels stay put.The affinity CRD field is schemaless so we accept a normal Kubernetes affinity object without inlining the full OpenAPI schema into the ClusterPolicy CRD.
Testing