@@ -41,6 +41,11 @@ import (
4141 ctrl "sigs.k8s.io/controller-runtime"
4242)
4343
44+ var (
45+ // watchesCtx is used in log streaming to be able to get canceled via cancelWatches after ending the test suite.
46+ watchesCtx , cancelWatches = context .WithCancel (context .Background ())
47+ )
48+
4449func init () {
4550 flag .StringVar (& configPath , "e2e.config" , "" , "path to the e2e config file" )
4651 flag .StringVar (& artifactFolder , "e2e.artifacts-folder" , "" , "folder where e2e test artifact should be stored" )
@@ -136,7 +141,7 @@ func loadE2EConfig(configPath string) *clusterctl.E2EConfig {
136141 config := clusterctl .LoadE2EConfig (context .TODO (), clusterctl.LoadE2EConfigInput {ConfigPath : configPath })
137142 Expect (config ).NotTo (BeNil (), "Failed to load E2E config from %s" , configPath )
138143
139- resolveKubernetesVersions (config )
144+ resolveKubernetesVersions (ctx , config )
140145
141146 return config
142147}
@@ -188,7 +193,7 @@ func setupBootstrapCluster(config *clusterctl.E2EConfig, useExistingCluster bool
188193}
189194
190195func initBootstrapCluster (bootstrapClusterProxy framework.ClusterProxy , config * clusterctl.E2EConfig , clusterctlConfig , artifactFolder string ) {
191- clusterctl .InitManagementClusterAndWatchControllerLogs (context . TODO () , clusterctl.InitManagementClusterAndWatchControllerLogsInput {
196+ clusterctl .InitManagementClusterAndWatchControllerLogs (watchesCtx , clusterctl.InitManagementClusterAndWatchControllerLogsInput {
192197 ClusterProxy : bootstrapClusterProxy ,
193198 ClusterctlConfigPath : clusterctlConfig ,
194199 InfrastructureProviders : config .InfrastructureProviders (),
@@ -198,6 +203,7 @@ func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config *
198203}
199204
200205func tearDown (bootstrapClusterProvider bootstrap.ClusterProvider , bootstrapClusterProxy framework.ClusterProxy ) {
206+ cancelWatches ()
201207 if bootstrapClusterProxy != nil {
202208 bootstrapClusterProxy .Dispose (context .TODO ())
203209 }
0 commit comments