Skip to content

Commit e1e92bc

Browse files
authored
Merge pull request kubernetes#128618 from knrc/error-check-fix
Fix error check
2 parents b35bbec + e7e1fb7 commit e1e92bc

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ func (d *dispatcher) dispatchInvocations(
162162
}
163163

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

0 commit comments

Comments
 (0)