@@ -130,7 +130,8 @@ func (rcStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorL
130
130
allErrs := corevalidation .ValidateReplicationController (controller , opts )
131
131
132
132
// If DeclarativeValidation feature gate is enabled, also run declarative validation
133
- if utilfeature .DefaultFeatureGate .Enabled (features .DeclarativeValidation ) {
133
+ // FIXME: isSpecRequest(ctx) limits Declarative validation to the spec until subresource support is introduced.
134
+ if utilfeature .DefaultFeatureGate .Enabled (features .DeclarativeValidation ) && isSpecRequest (ctx ) {
134
135
// Determine if takeover is enabled
135
136
takeover := utilfeature .DefaultFeatureGate .Enabled (features .DeclarativeValidationTakeover )
136
137
@@ -175,7 +176,6 @@ func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
175
176
newRc := obj .(* api.ReplicationController )
176
177
177
178
opts := pod .GetValidationOptionsFromPodTemplate (newRc .Spec .Template , oldRc .Spec .Template )
178
- // FIXME: Calling both validator functions here results in redundant calls to ValidateReplicationControllerSpec.
179
179
// This should be fixed to avoid the redundant calls, but carefully.
180
180
validationErrorList := corevalidation .ValidateReplicationController (newRc , opts )
181
181
updateErrorList := corevalidation .ValidateReplicationControllerUpdate (newRc , oldRc , opts )
@@ -199,7 +199,8 @@ func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
199
199
}
200
200
201
201
// If DeclarativeValidation feature gate is enabled, also run declarative validation
202
- if utilfeature .DefaultFeatureGate .Enabled (features .DeclarativeValidation ) {
202
+ // FIXME: This limits Declarative validation to the spec until subresource support is introduced.
203
+ if utilfeature .DefaultFeatureGate .Enabled (features .DeclarativeValidation ) && isSpecRequest (ctx ) {
203
204
// Determine if takeover is enabled
204
205
takeover := utilfeature .DefaultFeatureGate .Enabled (features .DeclarativeValidationTakeover )
205
206
@@ -218,6 +219,13 @@ func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
218
219
return errs
219
220
}
220
221
222
+ func isSpecRequest (ctx context.Context ) bool {
223
+ if requestInfo , found := genericapirequest .RequestInfoFrom (ctx ); found {
224
+ return len (requestInfo .Subresource ) == 0
225
+ }
226
+ return false
227
+ }
228
+
221
229
// WarningsOnUpdate returns warnings for the given update.
222
230
func (rcStrategy ) WarningsOnUpdate (ctx context.Context , obj , old runtime.Object ) []string {
223
231
var warnings []string
0 commit comments