Skip to content

Commit 74dfde1

Browse files
authored
Remove validatePodSpecUpdate from the validating webhook. (#187)
* Remove `validatePodSpecUpdate` from the validating webhook. Signed-off-by: Saketh Kalaga <saketh.kalaga@sap.com> --------- Signed-off-by: Saketh Kalaga <saketh.kalaga@sap.com>
1 parent bcc4121 commit 74dfde1

File tree

4 files changed

+3
-49
lines changed

4 files changed

+3
-49
lines changed

operator/client/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
5555
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
5656
github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM=
5757
github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM=
58-
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
59-
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
58+
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
59+
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
6060
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
6161
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
6262
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

operator/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require (
66
github.com/NVIDIA/grove/operator/api v0.0.0
77
github.com/NVIDIA/grove/scheduler/api v0.0.0
88
github.com/go-logr/logr v1.4.3
9-
github.com/google/uuid v1.6.0
109
github.com/open-policy-agent/cert-controller v0.13.0
1110
github.com/samber/lo v1.51.0
1211
github.com/spf13/pflag v1.0.7
@@ -35,6 +34,7 @@ require (
3534
github.com/google/btree v1.1.3 // indirect
3635
github.com/google/gnostic-models v0.7.0 // indirect
3736
github.com/google/go-cmp v0.7.0 // indirect
37+
github.com/google/uuid v1.6.0 // indirect
3838
github.com/josharian/intern v1.0.0 // indirect
3939
github.com/json-iterator/go v1.1.12 // indirect
4040
github.com/mailru/easyjson v0.9.0 // indirect

operator/internal/webhook/admission/pcs/validation/podcliqueset.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package validation
1818

1919
import (
2020
"fmt"
21-
"reflect"
2221
"slices"
2322
"strings"
2423

@@ -579,54 +578,11 @@ func validatePodCliqueUpdate(newCliques, oldCliques []*grovecorev1alpha1.PodCliq
579578
allErrs = append(allErrs, apivalidation.ValidateImmutableField(newClique.Spec.RoleName, oldIndexCliqueTuple.B.Spec.RoleName, cliqueFldPath.Child("roleName"))...)
580579
allErrs = append(allErrs, apivalidation.ValidateImmutableField(newClique.Spec.MinAvailable, oldIndexCliqueTuple.B.Spec.MinAvailable, cliqueFldPath.Child("minAvailable"))...)
581580
allErrs = append(allErrs, apivalidation.ValidateImmutableField(newClique.Spec.StartsAfter, oldIndexCliqueTuple.B.Spec.StartsAfter, cliqueFldPath.Child("startsAfter"))...)
582-
583-
allErrs = append(allErrs, validatePodSpecUpdate(&newClique.Spec.PodSpec, &oldIndexCliqueTuple.B.Spec.PodSpec, fldPath.Child("spec", "podSpec"))...)
584-
}
585-
586-
return allErrs
587-
}
588-
589-
func validatePodSpecUpdate(newSpec, oldSpec *corev1.PodSpec, fldPath *field.Path) field.ErrorList {
590-
allErrs := field.ErrorList{}
591-
592-
// spec: Forbidden: pod updates may not change fields other than:
593-
// `spec.containers[*].image`,
594-
// `spec.initContainers[*].image`,
595-
// `spec.activeDeadlineSeconds`,
596-
// `spec.tolerations` (only additions to existing tolerations),
597-
// `spec.terminationGracePeriodSeconds` (allow it to be set to 1 if it was previously negative)
598-
if len(newSpec.Tolerations) < len(oldSpec.Tolerations) || !reflect.DeepEqual(oldSpec.Tolerations, newSpec.Tolerations[:len(oldSpec.Tolerations)]) {
599-
allErrs = append(allErrs, field.Forbidden(fldPath.Child("tolerations"), "not allowed to change immutable pod fields"))
600-
}
601-
if oldSpec.TerminationGracePeriodSeconds != nil && *oldSpec.TerminationGracePeriodSeconds < 0 {
602-
// The only change that is allowed is to set this value to 1. All other modifications should be rejected.
603-
if newSpec.TerminationGracePeriodSeconds != nil && *newSpec.TerminationGracePeriodSeconds != 1 {
604-
allErrs = append(allErrs, field.Forbidden(fldPath.Child("terminationGracePeriodSeconds"), "value can only be set to 1 if previously negative"))
605-
}
606581
}
607-
// hide mutable fields
608-
spec1 := newSpec.DeepCopy()
609-
spec2 := oldSpec.DeepCopy()
610-
611-
clearContainerImages(spec1.Containers)
612-
clearContainerImages(spec2.Containers)
613-
clearContainerImages(spec1.InitContainers)
614-
clearContainerImages(spec2.InitContainers)
615-
spec1.ActiveDeadlineSeconds, spec2.ActiveDeadlineSeconds = nil, nil
616-
spec1.Tolerations, spec2.Tolerations = []corev1.Toleration{}, []corev1.Toleration{}
617-
spec1.TerminationGracePeriodSeconds, spec2.TerminationGracePeriodSeconds = nil, nil
618-
619-
allErrs = append(allErrs, apivalidation.ValidateImmutableField(spec1, spec2, fldPath)...)
620582

621583
return allErrs
622584
}
623585

624-
func clearContainerImages(containers []corev1.Container) {
625-
for i := range containers {
626-
containers[i].Image = ""
627-
}
628-
}
629-
630586
// validatePodNameConstraints validates Grove pod name component constraints.
631587
// This function validates the constraints for component names that will be used
632588
// to construct pod names.

scheduler/api/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ k8s.io/apiextensions-apiserver v0.32.2 h1:2YMk285jWMk2188V2AERy5yDwBYrjgWYggscgh
153153
k8s.io/apiextensions-apiserver v0.32.2/go.mod h1:GPwf8sph7YlJT3H6aKUWtd0E+oyShk/YHWQHf/OOgCA=
154154
k8s.io/apimachinery v0.33.1 h1:mzqXWV8tW9Rw4VeW9rEkqvnxj59k1ezDUl20tFK/oM4=
155155
k8s.io/apimachinery v0.33.1/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
156-
k8s.io/code-generator v0.33.0 h1:B212FVl6EFqNmlgdOZYWNi77yBv+ed3QgQsMR8YQCw4=
157-
k8s.io/code-generator v0.33.0/go.mod h1:KnJRokGxjvbBQkSJkbVuBbu6z4B0rC7ynkpY5Aw6m9o=
158156
k8s.io/code-generator v0.33.1 h1:ZLzIRdMsh3Myfnx9BaooX6iQry29UJjVfVG+BuS+UMw=
159157
k8s.io/code-generator v0.33.1/go.mod h1:HUKT7Ubp6bOgIbbaPIs9lpd2Q02uqkMCMx9/GjDrWpY=
160158
k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 h1:2OX19X59HxDprNCVrWi6jb7LW1PoqTlYqEq5H2oetog=

0 commit comments

Comments
 (0)