Skip to content

Commit e7e1fb7

Browse files
committed
Fix error check
Signed-off-by: Kevin Conner <[email protected]>
1 parent 62bdf5d commit e7e1fb7

File tree

1 file changed

+5
-6
lines changed
  • staging/src/k8s.io/apiserver/pkg/admission/plugin/policy/mutating

1 file changed

+5
-6
lines changed

staging/src/k8s.io/apiserver/pkg/admission/plugin/policy/mutating/dispatcher.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ func (d *dispatcher) dispatchInvocations(
161161
}
162162

163163
invocationKey, invocationKeyErr := keyFor(invocation)
164+
if invocationKeyErr != nil {
165+
// This should never happen. It occurs if there is a programming
166+
// error causing the Param not to be a valid object.
167+
return nil, k8serrors.NewInternalError(invocationKeyErr)
168+
}
164169
if reinvokeCtx.IsReinvoke() && !policyReinvokeCtx.ShouldReinvoke(invocationKey) {
165170
continue
166171
}
@@ -169,12 +174,6 @@ func (d *dispatcher) dispatchInvocations(
169174
// Mutations for a single invocation of a MutatingAdmissionPolicy are evaluated
170175
// in order.
171176
for mutationIndex := range invocation.Policy.Spec.Mutations {
172-
if invocationKeyErr != nil {
173-
// This should never happen. It occurs if there is a programming
174-
// error causing the Param not to be a valid object.
175-
return nil, k8serrors.NewInternalError(invocationKeyErr)
176-
}
177-
178177
lastVersionedAttr = versionedAttr
179178
if versionedAttr.VersionedObject == nil { // Do not call patchers if there is no object to patch.
180179
continue

0 commit comments

Comments
 (0)