Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvegamyhre committed Nov 18, 2023
1 parent cedb1b6 commit feed6dd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/webhooks/pod_mutating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}
Expand Down

0 comments on commit feed6dd

Please sign in to comment.