Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Remove and reinstall BMO in source cluster before and after pivot #838

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 51 additions & 3 deletions test/e2e/pivoting.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ func pivoting(ctx context.Context, inputGetter func() PivotingInput) {
})
LogFromFile(filepath.Join(input.ArtifactFolder, "clusters", input.ClusterName+"-bootstrap", "logs", input.Namespace, "clusterctl-move.log"))

By("Remove BMO deployment from the source cluster")
RemoveDeployment(ctx, func() RemoveDeploymentInput {
return RemoveDeploymentInput{
ManagementCluster: input.BootstrapClusterProxy,
Namespace: input.E2EConfig.GetVariable(ironicNamespace),
Name: input.E2EConfig.GetVariable(NamePrefix) + "-controller-manager",
}
})

pivotingCluster := framework.DiscoveryAndWaitForCluster(ctx, framework.DiscoveryAndWaitForClusterInput{
Getter: input.TargetCluster.GetClient(),
Namespace: input.Namespace,
Expand Down Expand Up @@ -339,9 +348,13 @@ func removeIronic(ctx context.Context, inputGetter func() RemoveIronicInput) {
input := inputGetter()
if input.IsDeployment {
deploymentName := input.NamePrefix + "-ironic"
ironicNamespace := input.Namespace
err := input.ManagementCluster.GetClientSet().AppsV1().Deployments(ironicNamespace).Delete(ctx, deploymentName, metav1.DeleteOptions{})
Expect(err).To(BeNil(), "Failed to delete Ironic from the source cluster")
RemoveDeployment(ctx, func() RemoveDeploymentInput {
return RemoveDeploymentInput{
ManagementCluster: input.ManagementCluster,
Namespace: input.Namespace,
Name: deploymentName,
}
})
} else {
ironicContainerList := []string{
"ironic",
Expand All @@ -363,6 +376,21 @@ func removeIronic(ctx context.Context, inputGetter func() RemoveIronicInput) {
}
}

type RemoveDeploymentInput struct {
ManagementCluster framework.ClusterProxy
Namespace string
Name string
}

func RemoveDeployment(ctx context.Context, inputGetter func() RemoveDeploymentInput) {
input := inputGetter()

deploymentName := input.Name
ironicNamespace := input.Namespace
err := input.ManagementCluster.GetClientSet().AppsV1().Deployments(ironicNamespace).Delete(ctx, deploymentName, metav1.DeleteOptions{})
Expect(err).To(BeNil(), "Failed to delete %s Deployment", deploymentName)
}

func labelBMOCRDs(targetCluster framework.ClusterProxy) {
labels := []string{
"clusterctl.cluster.x-k8s.io=",
Expand Down Expand Up @@ -454,6 +482,26 @@ func rePivoting(ctx context.Context, inputGetter func() RePivotingInput) {
NamePrefix: input.E2EConfig.GetVariable(NamePrefix),
}
})

By("Reinstate BMO in Source cluster")
installIronicBMO(ctx, func() installIronicBMOInput {
return installIronicBMOInput{
ManagementCluster: input.BootstrapClusterProxy,
BMOPath: input.E2EConfig.GetVariable(bmoPath),
deployIronic: false,
deployBMO: true,
deployIronicTLSSetup: getBool(input.E2EConfig.GetVariable(ironicTLSSetup)),
deployIronicBasicAuth: getBool(input.E2EConfig.GetVariable(ironicBasicAuth)),
deployIronicKeepalived: getBool(input.E2EConfig.GetVariable(ironicKeepalived)),
deployIronicMariadb: getBool(input.E2EConfig.GetVariable(ironicMariadb)),
Namespace: input.E2EConfig.GetVariable(ironicNamespace),
NamePrefix: input.E2EConfig.GetVariable(NamePrefix),
RestartContainerCertUpdate: getBool(input.E2EConfig.GetVariable(restartContainerCertUpdate)),
E2EConfig: input.E2EConfig,
SpecName: input.SpecName,
}
})

By("Reinstate Ironic containers and BMH")
// TODO(mboukhalfa): add this local ironic deployment case to installIronicBMO function
ephemeralCluster := os.Getenv("EPHEMERAL_CLUSTER")
Expand Down