From 4d6a63cd298afd6987236f463a327d9f3f39dc09 Mon Sep 17 00:00:00 2001 From: Lennart Jern Date: Wed, 22 Jan 2025 10:51:52 +0000 Subject: [PATCH] E2E: Delete BMHs prior to namespace deletion Sometimes the fixture tests hit the timeout for namespace deletion. The BMO logs indicate that BMO is trying to create new objects while the namespace is terminating. For example HardwareDetails. To avoid this, I think we can trigger deletion of the BMHs before we delete the namespace. We are running a bit close to the 1m deadline on successful runs in the re-inspection test. I believe this is explained by an extra reconcile loop when the hardwaredetails are updated because of the inspection. No other fixture test is close to this deadline normally. Signed-off-by: Lennart Jern --- test/e2e/common.go | 16 ++++++++++++++++ test/e2e/config/fixture.yaml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/e2e/common.go b/test/e2e/common.go index 880b69bd51..59ff1850a9 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -84,6 +84,18 @@ func WaitForBmhInProvisioningState(ctx context.Context, input WaitForBmhInProvis }, intervals...).Should(Succeed()) } +// DeleteBmhsInNamespace deletes all BMHs in the given namespace. +func DeleteBmhsInNamespace(ctx context.Context, deleter client.Client, namespace string) { + bmh := metal3api.BareMetalHost{} + opts := client.DeleteAllOfOptions{ + ListOptions: client.ListOptions{ + Namespace: namespace, + }, + } + err := deleter.DeleteAllOf(ctx, &bmh, &opts) + Expect(err).NotTo(HaveOccurred(), "Unable to delete BMHs") +} + // WaitForBmhDeletedInput is the input for WaitForBmhDeleted. type WaitForBmhDeletedInput struct { Client client.Client @@ -134,6 +146,10 @@ func WaitForNamespaceDeleted(ctx context.Context, input WaitForNamespaceDeletedI } func cleanup(ctx context.Context, clusterProxy framework.ClusterProxy, namespace *corev1.Namespace, cancelWatches context.CancelFunc, intervals ...interface{}) { + // Trigger deletion of BMHs before deleting the namespace. + // This way there should be no risk of BMO getting stuck trying to progress + // and create HardwareDetails or similar, while the namespace is terminating. + DeleteBmhsInNamespace(ctx, clusterProxy.GetClient(), namespace.Name) framework.DeleteNamespace(ctx, framework.DeleteNamespaceInput{ Deleter: clusterProxy.GetClient(), Name: namespace.Name, diff --git a/test/e2e/config/fixture.yaml b/test/e2e/config/fixture.yaml index ab2ba48595..9395df65c5 100644 --- a/test/e2e/config/fixture.yaml +++ b/test/e2e/config/fixture.yaml @@ -40,7 +40,7 @@ intervals: inspection/wait-available: ["5s", "10ms"] external-inspection/wait-available: ["5s", "1ms"] default/wait-deployment: ["5m", "1s"] - default/wait-namespace-deleted: ["1m", "1s"] + default/wait-namespace-deleted: ["2m", "1s"] ironic/wait-deployment: ["10m", "2s"] default/wait-registration: ["5s", "5ms"] default/wait-provisioning: ["1m", "10ms"]