mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
default admission hook failure safely
This commit is contained in:
parent
f07b359e5b
commit
4e79357f9f
@ -191,7 +191,7 @@ func (a *GenericAdmissionWebhook) Admit(attr admission.Attributes) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreClientCallFailures := hook.FailurePolicy == nil || *hook.FailurePolicy == v1alpha1.Ignore
|
ignoreClientCallFailures := hook.FailurePolicy != nil && *hook.FailurePolicy == v1alpha1.Ignore
|
||||||
if callErr, ok := err.(*ErrCallingWebhook); ok {
|
if callErr, ok := err.(*ErrCallingWebhook); ok {
|
||||||
if ignoreClientCallFailures {
|
if ignoreClientCallFailures {
|
||||||
glog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
|
glog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
|
||||||
|
@ -216,7 +216,7 @@ func TestAdmit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectAllow: true,
|
expectAllow: true,
|
||||||
},
|
},
|
||||||
"match & fail (but allow because fail open on nil)": {
|
"match & fail (but disallow because fail closed on nil)": {
|
||||||
hookSource: fakeHookSource{
|
hookSource: fakeHookSource{
|
||||||
hooks: []registrationv1alpha1.ExternalAdmissionHook{{
|
hooks: []registrationv1alpha1.ExternalAdmissionHook{{
|
||||||
Name: "internalErr A",
|
Name: "internalErr A",
|
||||||
@ -232,7 +232,7 @@ func TestAdmit(t *testing.T) {
|
|||||||
Rules: matchEverythingRules,
|
Rules: matchEverythingRules,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
expectAllow: true,
|
expectAllow: false,
|
||||||
},
|
},
|
||||||
"match & fail (but fail because fail closed)": {
|
"match & fail (but fail because fail closed)": {
|
||||||
hookSource: fakeHookSource{
|
hookSource: fakeHookSource{
|
||||||
|
Loading…
Reference in New Issue
Block a user