@@ -34,21 +34,6 @@ import (
34
34
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/metrics/admission"
35
35
)
36
36
37
- var (
38
- possibleUpdateModes = map [vpa_types.UpdateMode ]interface {}{
39
- vpa_types .UpdateModeOff : struct {}{},
40
- vpa_types .UpdateModeInitial : struct {}{},
41
- vpa_types .UpdateModeRecreate : struct {}{},
42
- vpa_types .UpdateModeAuto : struct {}{},
43
- vpa_types .UpdateModeInPlaceOrRecreate : struct {}{},
44
- }
45
-
46
- possibleScalingModes = map [vpa_types.ContainerScalingMode ]interface {}{
47
- vpa_types .ContainerScalingModeAuto : struct {}{},
48
- vpa_types .ContainerScalingModeOff : struct {}{},
49
- }
50
- )
51
-
52
37
// resourceHandler builds patches for VPAs.
53
38
type resourceHandler struct {
54
39
preProcessor PreProcessor
@@ -127,12 +112,6 @@ func ValidateVPA(vpa *vpa_types.VerticalPodAutoscaler, isCreate bool) error {
127
112
128
113
if vpa .Spec .ResourcePolicy != nil {
129
114
for _ , policy := range vpa .Spec .ResourcePolicy .ContainerPolicies {
130
- mode := policy .Mode
131
- if mode != nil {
132
- if _ , found := possibleScalingModes [* mode ]; ! found {
133
- return fmt .Errorf ("unexpected Mode value %s" , * mode )
134
- }
135
- }
136
115
for resource , min := range policy .MinAllowed {
137
116
if err := validateResourceResolution (resource , min ); err != nil {
138
117
return fmt .Errorf ("MinAllowed: %v" , err )
@@ -149,6 +128,7 @@ func ValidateVPA(vpa *vpa_types.VerticalPodAutoscaler, isCreate bool) error {
149
128
}
150
129
}
151
130
ControlledValues := policy .ControlledValues
131
+ mode := policy .Mode
152
132
if mode != nil && ControlledValues != nil {
153
133
if * mode == vpa_types .ContainerScalingModeOff && * ControlledValues == vpa_types .ContainerControlledValuesRequestsAndLimits {
154
134
return fmt .Errorf ("controlledValues shouldn't be specified if container scaling mode is off." )
0 commit comments