diff --git a/pkg/webhooks/pod_mutating_webhook.go b/pkg/webhooks/pod_mutating_webhook.go index 766ccb211..a887883db 100644 --- a/pkg/webhooks/pod_mutating_webhook.go +++ b/pkg/webhooks/pod_mutating_webhook.go @@ -62,8 +62,8 @@ func (p *podWebhook) Default(ctx context.Context, obj runtime.Object) error { return nil } // If this pod is part of a JobSet that is NOT using the exclusive placement feature, - // or if this jobset is using the node selector exclusive placement strategy, we don't need - // to mutate the pod here. + // or if this jobset is using the node selector exclusive placement strategy (running + // the hack/label_nodes.py script beforehand), we don't need to mutate the pod here. _, usingExclusivePlacement := pod.Annotations[jobset.ExclusiveKey] _, usingNodeSelectorStrategy := pod.Annotations[jobset.NodeSelectorStrategyKey] if !usingExclusivePlacement || usingNodeSelectorStrategy { @@ -72,17 +72,17 @@ func (p *podWebhook) Default(ctx context.Context, obj runtime.Object) error { return p.patchPod(ctx, pod) } -// patchPod will only add exclusive affinites to pod index 0. For all pods besides pod index 0, -// it will add a scheduling gate to prevent them from scheduling initially. +// patchPod will add exclusive affinites to pod index 0, and for all pods +// it will add a nodeSelector selecting the same topology as pod index 0 is +// scheduled on. func (p *podWebhook) patchPod(ctx context.Context, pod *corev1.Pod) error { log := ctrl.LoggerFrom(ctx) - // If this pod is part of a JobSet which is usig the node selector strategy for exclusive if pod.Annotations[batchv1.JobCompletionIndexAnnotation] == "0" { - log.Info("pod webhook: setting exclusive affinities for node selector exclusive placement strategy") + log.Info(fmt.Sprintf("pod webhook: setting exclusive affinities for pod: %s", pod.Name)) setExclusiveAffinities(pod) return nil } else { - log.Info("pod webhook: adding node affinity for follower pod for node selector exclusive placement strategy") + log.Info(fmt.Sprintf("pod webhook: adding node selector for follower pod: %s", pod.Name)) return p.setNodeSelector(ctx, pod) } }