New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle panic during validating admission webhook admission #108746
Conversation
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/plugin_test.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/dispatcher.go
Outdated
Show resolved
Hide resolved
/triage accepted |
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/dispatcher.go
Outdated
Show resolved
Hide resolved
2bd12bf
to
ba53c2d
Compare
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/dispatcher.go
Outdated
Show resolved
Hide resolved
726ecba
to
13a35f1
Compare
/hold cancel |
/priority important-soon |
defer wg.Done() | ||
defer func() { | ||
// HandleCrash has already called the crash handlers and it has been configured to utilruntime.ReallyCrash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: weird double spaces in comments here and above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: weird double spaces in comments here and above
I miss my double spaces after periods
}}, | ||
ExpectStatusCode: http.StatusInternalServerError, | ||
ExpectAllow: false, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no panic-related error message here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no panic-related error message here?
added
} | ||
if ignoreClientCallFailures { | ||
// if failures are supposed to ignored, ignore it | ||
klog.Warningf("Panic calling webhook, failing open %v: %v", invocation.Webhook.GetName(), r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't invocation.Webhook.GetName() the same as hookName
? did you mean GetConfigurationName()?
return | ||
} | ||
// this ensures that the admission request fails and a message is provided. | ||
errCh <- apierrors.NewInternalError(fmt.Errorf("ValidatingAdmissionWebhook/%v has panicked: %v", invocation.Webhook.GetName(), r)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't invocation.Webhook.GetName() the same as hookName
? did you mean GetConfigurationName()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't invocation.Webhook.GetName() the same as hookName? did you mean GetConfigurationName()?
other errors here use hookName. Updated for variable instead of method.
mm... looks like the unit test needs to tolerate whichever message comes first: plugin_test.go:332: match & fail (but fail because fail closed): expected an error saying "ValidatingAdmissionWebhook/internalErr B has panicked: Start panicking!", but got Internal error occurred: ValidatingAdmissionWebhook/internalErr C has panicked: Start panicking! |
Validating admission webhook evaluation can fail, if uncaught this crashes a kube-apiserver. Add handling to catch panic while preserving the behavior of "must not fail".
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, liggitt The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Validating admission webhook evaluation can fail, if uncaught this
crashes a kube-apiserver. Add handling to catch panic while preserving
the behavior of "must not fail".
/kind bug
/priority important-soon
/sig api-machinery