Skip to content
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

fix(webhook): update webhook config sideEffects to None #1774

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/webhook/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ var (
Ignore = v1beta1.Ignore
// Fail means that an error calling the webhook causes the admission to fail.
Fail = v1beta1.Fail
// SideEffectClassNone means that calling the webhook will have no side effects.
SideEffectClassNone = v1beta1.SideEffectClassNone
// WebhookFailurePolicye represents failure policy env name to make it configurable
// via ENV
WebhookFailurePolicy = "ADMISSION_WEBHOOK_FAILURE_POLICY"
Expand All @@ -82,6 +84,7 @@ var (
addCVCWithUpdateRule,
addSPCWithDeleteRule,
addNSWithDeleteRule,
addSideEffects,
}
cvcRuleWithOperations = v1beta1.RuleWithOperations{
Operations: []v1beta1.OperationType{
Expand Down Expand Up @@ -237,6 +240,7 @@ func createValidatingWebhookConfig(
},
TimeoutSeconds: &five,
FailurePolicy: failurePolicy(),
SideEffects: &SideEffectClassNone,
}

validator := &v1beta1.ValidatingWebhookConfiguration{
Expand Down Expand Up @@ -525,6 +529,12 @@ func addNSWithDeleteRule(config *v1beta1.ValidatingWebhookConfiguration) {
}
}

func addSideEffects(config *v1beta1.ValidatingWebhookConfiguration) {
if util.IsCurrentLessThanNewVersion(config.Labels[string(apis.OpenEBSVersionKey)], "2.4.0") {
config.Webhooks[0].SideEffects = &SideEffectClassNone
}
}

func getOldService(openebsNamespace string) (*corev1.ServiceList, error) {
v100SVCName := "admission-server-svc"
// fetch service 1.1.0 onwards based on label
Expand Down