Skip to content

Commit

Permalink
Cleanup resources from DeploymentFailure upgrade test (#15227)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgencur committed May 23, 2024
1 parent 5ebffd5 commit fa7eaa2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/upgrade/deployment_failure.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (
v1test "knative.dev/serving/test/v1"
)

const (
webhookName = "broken-webhook"
)

func DeploymentFailurePostUpgrade() pkgupgrade.Operation {
return pkgupgrade.NewOperation("DeploymentFailurePostUpgrade", func(c pkgupgrade.Context) {
clients := e2e.Setup(c.T)
Expand All @@ -39,6 +43,13 @@ func DeploymentFailurePostUpgrade() pkgupgrade.Operation {
Service: "deployment-upgrade-failure",
Image: test.HelloWorld,
}
test.EnsureCleanup(c.T, func() {
if err := clients.KubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Delete(
context.Background(), webhookName, metav1.DeleteOptions{}); err != nil {
c.T.Fatal("Failed to delete webhook:", err)
}
test.TearDown(clients, &names)
})

service, err := clients.ServingClient.Services.Get(context.Background(), names.Service, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -100,7 +111,7 @@ func DeploymentFailurePreUpgrade() pkgupgrade.Operation {
ctx,
&admissionv1.MutatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: "broken-webhook",
Name: webhookName,
},
Webhooks: []admissionv1.MutatingWebhook{{
AdmissionReviewVersions: []string{"v1"},
Expand Down

0 comments on commit fa7eaa2

Please sign in to comment.