@@ -66,7 +66,7 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
6666 ctx context.Context
6767
6868 // Cleanup functions which cannot run until after the cluster has been deleted
69- postClusterCleanup []func ()
69+ postClusterCleanup []func (context. Context )
7070 )
7171
7272 BeforeEach (func () {
@@ -406,11 +406,10 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
406406 md3Name := clusterName + "-md-3"
407407 testSecurityGroupName := "testSecGroup"
408408 // create required test security group
409- Eventually (func () int {
410- err := shared .CreateOpenStackSecurityGroup (e2eCtx , testSecurityGroupName , "Test security group" )
411- Expect (err ).To (BeNil ())
412- return 1
413- }, e2eCtx .E2EConfig .GetIntervals (specName , "wait-worker-nodes" )... ).Should (Equal (1 ))
409+ var securityGroupCleanup func (ctx context.Context )
410+ securityGroupCleanup , err = shared .CreateOpenStackSecurityGroup (ctx , e2eCtx , testSecurityGroupName , "Test security group" )
411+ Expect (err ).To (BeNil ())
412+ postClusterCleanup = append (postClusterCleanup , securityGroupCleanup )
414413
415414 customPortOptions := & []infrav1.PortOpts {
416415 {
@@ -496,17 +495,17 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
496495
497496 extraNet1 , err = shared .CreateOpenStackNetwork (e2eCtx , fmt .Sprintf ("%s-extraNet1" , namespace .Name ), "10.14.0.0/24" )
498497 Expect (err ).NotTo (HaveOccurred ())
499- postClusterCleanup = append (postClusterCleanup , func () {
498+ postClusterCleanup = append (postClusterCleanup , func (ctx context. Context ) {
500499 shared .Logf ("Deleting additional network %s" , extraNet1 .Name )
501- err := shared .DeleteOpenStackNetwork (e2eCtx , extraNet1 .ID )
500+ err := shared .DeleteOpenStackNetwork (ctx , e2eCtx , extraNet1 .ID )
502501 Expect (err ).NotTo (HaveOccurred ())
503502 })
504503
505504 extraNet2 , err = shared .CreateOpenStackNetwork (e2eCtx , fmt .Sprintf ("%s-extraNet2" , namespace .Name ), "10.14.1.0/24" )
506505 Expect (err ).NotTo (HaveOccurred ())
507- postClusterCleanup = append (postClusterCleanup , func () {
506+ postClusterCleanup = append (postClusterCleanup , func (ctx context. Context ) {
508507 shared .Logf ("Deleting additional network %s" , extraNet2 .Name )
509- err := shared .DeleteOpenStackNetwork (e2eCtx , extraNet2 .ID )
508+ err := shared .DeleteOpenStackNetwork (ctx , e2eCtx , extraNet2 .ID )
510509 Expect (err ).NotTo (HaveOccurred ())
511510 })
512511
@@ -806,15 +805,15 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
806805 })
807806 })
808807
809- AfterEach (func () {
808+ AfterEach (func (ctx context. Context ) {
810809 shared .Logf ("Attempting to collect logs for cluster %q in namespace %q" , clusterResources .Cluster .Name , namespace .Name )
811810 e2eCtx .Environment .BootstrapClusterProxy .CollectWorkloadClusterLogs (ctx , namespace .Name , clusterResources .Cluster .Name , filepath .Join (e2eCtx .Settings .ArtifactFolder , "clusters" , e2eCtx .Environment .BootstrapClusterProxy .GetName (), namespace .Name ))
812811 // Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
813812 shared .DumpSpecResourcesAndCleanup (ctx , specName , namespace , e2eCtx )
814813
815814 // Cleanup resources which can't be cleaned up until the cluster has been deleted
816815 for _ , cleanup := range postClusterCleanup {
817- cleanup ()
816+ cleanup (ctx )
818817 }
819818 })
820819})
0 commit comments