@@ -26,18 +26,19 @@ var _ = Describe("When testing cluster upgrade v1alpha5 > current [upgrade]", fu
2626 })
2727 capi_e2e .ClusterctlUpgradeSpec (ctx , func () capi_e2e.ClusterctlUpgradeSpecInput {
2828 return capi_e2e.ClusterctlUpgradeSpecInput {
29- E2EConfig : e2eConfig ,
30- ClusterctlConfigPath : clusterctlConfigPath ,
31- BootstrapClusterProxy : bootstrapClusterProxy ,
32- ArtifactFolder : artifactFolder ,
33- SkipCleanup : true , // TODO(mboukhalfa): Parameterize after merging https://github.com/kubernetes-sigs/cluster-api/pull/7373
34- InitWithProvidersContract : "v1alpha4" ,
35- InitWithBinary : e2eConfig .GetVariable ("INIT_WITH_BINARY" ),
36- PreInit : preInitFunc ,
37- PreWaitForCluster : preWaitForCluster ,
38- PreUpgrade : preUpgrade ,
39- MgmtFlavor : osType ,
40- WorkloadFlavor : osType ,
29+ E2EConfig : e2eConfig ,
30+ ClusterctlConfigPath : clusterctlConfigPath ,
31+ BootstrapClusterProxy : bootstrapClusterProxy ,
32+ ArtifactFolder : artifactFolder ,
33+ SkipCleanup : skipCleanup ,
34+ InitWithProvidersContract : "v1alpha4" ,
35+ InitWithBinary : e2eConfig .GetVariable ("INIT_WITH_BINARY" ),
36+ PreInit : preInitFunc ,
37+ PreWaitForCluster : preWaitForCluster ,
38+ PreUpgrade : preUpgrade ,
39+ PreCleanupManagementCluster : preCleanupManagementCluster ,
40+ MgmtFlavor : osType ,
41+ WorkloadFlavor : osType ,
4142 }
4243 })
4344})
@@ -152,3 +153,27 @@ func preUpgrade(clusterProxy framework.ClusterProxy) {
152153 upgradeIronic (clusterProxy .GetClientSet ())
153154 upgradeBMO (clusterProxy .GetClientSet ())
154155}
156+
157+ // preCleanupManagementCluster hook should be called from ClusterctlUpgradeSpec before cleaning the target management cluster
158+ // it moves back Ironic to the bootstrap cluster.
159+ func preCleanupManagementCluster (clusterProxy framework.ClusterProxy ) {
160+ // Reinstall ironic
161+ reInstallIronic := func () {
162+ By ("Reinstate Ironic containers and BMH" )
163+ ephemeralCluster := os .Getenv ("EPHEMERAL_CLUSTER" )
164+ if ephemeralCluster == KIND {
165+ By ("Install Ironic in the source cluster as containers" )
166+ bmoPath := e2eConfig .GetVariable ("BMOPATH" )
167+ ironicCommand := bmoPath + "/tools/run_local_ironic.sh"
168+ cmd := exec .Command ("sh" , "-c" , "export CONTAINER_RUNTIME=docker; " + ironicCommand )
169+ stdoutStderr , err := cmd .CombinedOutput ()
170+ fmt .Printf ("%s\n " , stdoutStderr )
171+ Expect (err ).To (BeNil (), "Cannot run local ironic" )
172+ } else {
173+ By ("Install Ironic in the source cluster as deployments" )
174+ installIronicBMO (bootstrapClusterProxy , "true" , "false" )
175+ }
176+ }
177+ removeIronicDeploymentOnTarget (clusterProxy )
178+ reInstallIronic ()
179+ }
0 commit comments