Skip to content

Commit 1c04a72

Browse files
committed
style: strip comments from pod resize validator
Signed-off-by: gshaibi <gshaibi@nvidia.com>
1 parent ab63e5c commit 1c04a72

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

pkg/admission/webhook/v1alpha2/podhooks/pod_resize_validator.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ var resizeLog = logf.Log.WithName("pod-resize-validator")
2424
// memoryLimitBytesPerUnit converts a Queue Memory.Limit (in megabytes) to bytes.
2525
const memoryLimitBytesPerUnit = 1_000_000
2626

27-
// PodResizeValidator enforces best-effort queue quota on pods/resize requests.
28-
// It checks that the resource delta of the resize would not push any queue on
29-
// the pod's hierarchy over its configured limit (all workloads) or over its
30-
// deserved quota for non-preemptible workloads.
3127
type PodResizeValidator struct {
3228
kubeClient client.Client
3329
schedulerName string
@@ -58,8 +54,6 @@ func (v *PodResizeValidator) ValidateUpdate(ctx context.Context, oldPod, newPod
5854
return nil, v.validateResize(ctx, oldPod, newPod)
5955
}
6056

61-
// ValidateCreate and ValidateDelete never fire: the webhook is registered only
62-
// for UPDATE operations on the pods/resize subresource.
6357
func (v *PodResizeValidator) ValidateCreate(context.Context, *corev1.Pod) (admission.Warnings, error) {
6458
return nil, nil
6559
}
@@ -81,15 +75,13 @@ func (v *PodResizeValidator) validateResize(ctx context.Context, oldPod, newPod
8175
pg := &v2alpha2.PodGroup{}
8276
if err := v.kubeClient.Get(ctx, client.ObjectKey{Namespace: oldPod.Namespace, Name: pgName}, pg); err != nil {
8377
resizeLog.Error(err, "failed to get PodGroup", "namespace", oldPod.Namespace, "name", pgName)
84-
return nil // best-effort: allow on lookup failure
78+
return nil
8579
}
8680

87-
// Same resolution the podgroup-controller uses to populate
88-
// AllocatedNonPreemptible — the checker and the accountant must agree.
8981
isPreemptible, err := commonpodgroup.IsPreemptible(ctx, pg, v.kubeClient)
9082
if err != nil {
9183
resizeLog.Error(err, "failed to resolve preemptibility", "podgroup", pgName)
92-
isPreemptible = true // conservative: treat unknown as preemptible
84+
isPreemptible = true
9385
}
9486

9587
delta := podResizeDelta(oldPod, newPod)
@@ -102,7 +94,7 @@ func (v *PodResizeValidator) validateResize(ctx context.Context, oldPod, newPod
10294
queue := &v2.Queue{}
10395
if err := v.kubeClient.Get(ctx, client.ObjectKey{Name: queueName}, queue); err != nil {
10496
resizeLog.Error(err, "failed to get queue", "queue", queueName)
105-
return nil // best-effort: allow on lookup failure
97+
return nil
10698
}
10799

108100
if err := checkQueueCapacity(queue, delta, isPreemptible, v.blockUpsizeOnBoundedQueues, oldPod, pg); err != nil {
@@ -115,12 +107,6 @@ func (v *PodResizeValidator) validateResize(ctx context.Context, oldPod, newPod
115107
return nil
116108
}
117109

118-
// podResizeDelta computes the net per-resource increase this resize introduces
119-
// relative to what the queue already accounts for. All aggregates use the same
120-
// upstream helper as scheduler accounting, so the effectiveOld baseline matches
121-
// what the queue charges by construction. A resource whose pod-level spec is
122-
// unchanged is skipped: it is not part of this resize, and an unresolved
123-
// Infeasible spec on it must not produce phantom delta.
124110
func podResizeDelta(oldPod, newPod *corev1.Pod) corev1.ResourceList {
125111
specOnly := resourcehelpers.PodResourcesOptions{}
126112
withStatus := resourcehelpers.PodResourcesOptions{UseStatusResources: true}
@@ -178,9 +164,6 @@ func checkQueueCapacity(
178164
return nil
179165
}
180166

181-
// checkBlockUpsizeOnBoundedQueue rejects any upsize when a queue has a finite
182-
// limit (all workloads) or a finite quota (non-preemptible workloads), regardless
183-
// of current allocation. This prevents races between concurrent resize requests.
184167
func checkBlockUpsizeOnBoundedQueue(
185168
queue *v2.Queue,
186169
delta corev1.ResourceList,
@@ -225,13 +208,11 @@ func checkBlockUpsizeOnBoundedQueue(
225208
return nil
226209
}
227210

228-
// checkCapacityBound rejects the resize when adding delta to the given allocated
229-
// pool would exceed a finite bound (-1 means unbounded).
230211
func checkCapacityBound(
231-
boundKind string, // "limit" | "quota"
212+
boundKind string,
232213
cpuBound, memBound float64,
233214
allocated corev1.ResourceList,
234-
allocatedLabel string, // "Allocated" | "AllocatedNonPreemptible"
215+
allocatedLabel string,
235216
delta corev1.ResourceList,
236217
queue *v2.Queue,
237218
pod *corev1.Pod,

0 commit comments

Comments
 (0)