Skip to content

Commit

Permalink
E2E: Delete BMHs prior to namespace deletion
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lentzi90 committed Jan 28, 2025
1 parent 5e38d77 commit 182250b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config/fixture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 182250b

Please sign in to comment.