From 9b636902c6136d8624a1798b3c02b593d8b8b58a Mon Sep 17 00:00:00 2001 From: zanuka Date: Fri, 21 Mar 2025 16:03:37 -0700 Subject: [PATCH 1/4] updates mutate and validate web hook configs Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter.go | 4 ++++ pkg/release/util/kind_sorter_test.go | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/release/util/kind_sorter.go b/pkg/release/util/kind_sorter.go index 22795733c..72f99e115 100644 --- a/pkg/release/util/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -65,12 +65,16 @@ var InstallOrder KindSortOrder = []string{ "IngressClass", "Ingress", "APIService", + "MutatingWebhookConfiguration", + "ValidatingWebhookConfiguration", } // UninstallOrder is the order in which manifests should be uninstalled (by Kind). // // Those occurring earlier in the list get uninstalled before those occurring later in the list. var UninstallOrder KindSortOrder = []string{ + "ValidatingWebhookConfiguration", + "MutatingWebhookConfiguration", "APIService", "Ingress", "IngressClass", diff --git a/pkg/release/util/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go index 00d80ecf2..919de24e5 100644 --- a/pkg/release/util/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -173,6 +173,14 @@ func TestKindSorter(t *testing.T) { Name: "F", Head: &SimpleHead{Kind: "PriorityClass"}, }, + { + Name: "M", + Head: &SimpleHead{Kind: "MutatingWebhookConfiguration"}, + }, + { + Name: "V", + Head: &SimpleHead{Kind: "ValidatingWebhookConfiguration"}, + }, } for _, test := range []struct { @@ -180,8 +188,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvw!"}, - {"uninstall", UninstallOrder, "wvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, + {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvwMV!"}, + {"uninstall", UninstallOrder, "VMwvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) { From c121b6b83ee5a8c4439a347704fcc61032d2dbe6 Mon Sep 17 00:00:00 2001 From: Mike Delucchi Date: Fri, 28 Mar 2025 13:32:09 -0700 Subject: [PATCH 2/4] changes order of operations Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/release/util/kind_sorter.go b/pkg/release/util/kind_sorter.go index 72f99e115..27b44cc36 100644 --- a/pkg/release/util/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -64,18 +64,18 @@ var InstallOrder KindSortOrder = []string{ "CronJob", "IngressClass", "Ingress", - "APIService", "MutatingWebhookConfiguration", "ValidatingWebhookConfiguration", + "APIService", } // UninstallOrder is the order in which manifests should be uninstalled (by Kind). // // Those occurring earlier in the list get uninstalled before those occurring later in the list. var UninstallOrder KindSortOrder = []string{ + "APIService", "ValidatingWebhookConfiguration", "MutatingWebhookConfiguration", - "APIService", "Ingress", "IngressClass", "Service", From 1003a3c93f42b47293f3e53cacc51e09bf59278a Mon Sep 17 00:00:00 2001 From: Mike Delucchi Date: Mon, 31 Mar 2025 12:24:56 -0700 Subject: [PATCH 3/4] fixes kind_sorter_test to match new order Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/release/util/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go index 919de24e5..2a607ddd8 100644 --- a/pkg/release/util/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -188,8 +188,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvwMV!"}, - {"uninstall", UninstallOrder, "VMwvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, + {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvMVw!"}, + {"uninstall", UninstallOrder, "wVMvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) { From e1425f1aa56dbe1d51d40a721bb302707a7c9041 Mon Sep 17 00:00:00 2001 From: Mike Delucchi Date: Fri, 4 Apr 2025 10:44:42 -0700 Subject: [PATCH 4/4] fix: correct webhook order to match Kubernetes admission flow Place APIService before webhooks, with MutatingWebhookConfiguration before ValidatingWebhookConfiguration to match standard admission control. Signed-off-by: Mike Delucchi --- pkg/release/util/kind_sorter.go | 5 +++-- pkg/release/util/kind_sorter_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/release/util/kind_sorter.go b/pkg/release/util/kind_sorter.go index 27b44cc36..bc074340f 100644 --- a/pkg/release/util/kind_sorter.go +++ b/pkg/release/util/kind_sorter.go @@ -64,18 +64,19 @@ var InstallOrder KindSortOrder = []string{ "CronJob", "IngressClass", "Ingress", + "APIService", "MutatingWebhookConfiguration", "ValidatingWebhookConfiguration", - "APIService", } // UninstallOrder is the order in which manifests should be uninstalled (by Kind). // // Those occurring earlier in the list get uninstalled before those occurring later in the list. var UninstallOrder KindSortOrder = []string{ - "APIService", + // For uninstall, we remove validation before mutation to ensure webhooks don't block removal "ValidatingWebhookConfiguration", "MutatingWebhookConfiguration", + "APIService", "Ingress", "IngressClass", "Service", diff --git a/pkg/release/util/kind_sorter_test.go b/pkg/release/util/kind_sorter_test.go index 2a607ddd8..919de24e5 100644 --- a/pkg/release/util/kind_sorter_test.go +++ b/pkg/release/util/kind_sorter_test.go @@ -188,8 +188,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvMVw!"}, - {"uninstall", UninstallOrder, "wVMvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, + {"install", InstallOrder, "FaAbcC3deEf1gh2iIjJkKlLmnopqrxstuUvwMV!"}, + {"uninstall", UninstallOrder, "VMwvUmutsxrqponLlKkJjIi2hg1fEed3CcbAaF!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) {