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

[release-0.19] Adding logic to apply new hardware on tink upgrades #8295

Merged
Show file tree
Hide file tree
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
16 changes: 14 additions & 2 deletions pkg/providers/tinkerbell/tinkerbell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ func TestSetupAndValidateUpgradeWorkloadClusterErrorApplyHardware(t *testing.T)
kubectl := mocks.NewMockProviderKubectlClient(mockCtrl)
stackInstaller := stackmocks.NewMockStackInstaller(mockCtrl)
writer := filewritermocks.NewMockFileWriter(mockCtrl)
cluster := &types.Cluster{Name: "test"}
cluster := &types.Cluster{Name: "management-cluster"}
forceCleanup := false

clusterSpec := givenClusterSpec(t, clusterSpecManifest)
Expand Down Expand Up @@ -1591,7 +1591,7 @@ func TestSetupAndValidateUpgradeWorkloadClusterErrorBMC(t *testing.T) {
kubectl := mocks.NewMockProviderKubectlClient(mockCtrl)
stackInstaller := stackmocks.NewMockStackInstaller(mockCtrl)
writer := filewritermocks.NewMockFileWriter(mockCtrl)
cluster := &types.Cluster{Name: "test"}
cluster := &types.Cluster{Name: "management-cluster"}
forceCleanup := false

clusterSpec := givenClusterSpec(t, clusterSpecManifest)
Expand Down Expand Up @@ -2128,6 +2128,12 @@ func TestTinkerbellProvider_GenerateCAPISpecForUpgrade_RegistryMirror(t *testing
kubectl.EXPECT().
GetMachineDeployment(gomock.Any(), gomock.Any(), gomock.Any()).
Return(machineDeployment, nil)
kubectl.EXPECT().
ApplyKubeSpecFromBytesForce(ctx, cluster, gomock.Any()).
Return(nil)
kubectl.EXPECT().
WaitForRufioMachines(ctx, cluster, "5m", "Contactable", gomock.Any()).
Return(nil)

provider := newProvider(datacenterConfig, machineConfigs, updatedClusterSpec.Cluster, writer, docker, helm, kubectl, false)
provider.stackInstaller = stackInstaller
Expand Down Expand Up @@ -2305,6 +2311,12 @@ func TestTinkerbellProvider_GenerateCAPISpecForUpgrade_CertBundles(t *testing.T)
kubectl.EXPECT().
GetMachineDeployment(gomock.Any(), gomock.Any(), gomock.Any()).
Return(machineDeployment, nil)
kubectl.EXPECT().
ApplyKubeSpecFromBytesForce(ctx, cluster, gomock.Any()).
Return(nil)
kubectl.EXPECT().
WaitForRufioMachines(ctx, cluster, "5m", "Contactable", gomock.Any()).
Return(nil)

provider := newProvider(datacenterConfig, machineConfigs, updatedClusterSpec.Cluster, writer, docker, helm, kubectl, false)
provider.stackInstaller = stackInstaller
Expand Down
20 changes: 12 additions & 8 deletions pkg/providers/tinkerbell/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *
}
p.stackInstaller.AddNoProxyIP(managementCluster.Spec.ControlPlaneConfiguration.Endpoint.Host)
}
}

if err := p.applyHardwareUpgrade(ctx, clusterSpec.ManagementCluster); err != nil {
return err
}
if p.catalogue.TotalHardware() > 0 && p.catalogue.AllHardware()[0].Spec.BMCRef != nil {
err = p.providerKubectlClient.WaitForRufioMachines(ctx, cluster, "5m", "Contactable", constants.EksaSystemNamespace)
if err != nil {
return fmt.Errorf("waiting for baseboard management to be contactable: %v", err)
}
if err := p.applyHardwareUpgrade(ctx, cluster); err != nil {
return err
}

// Check if the hardware in the catalogue have a BMCRef. Since we only allow either all hardware with bmc
// or no hardware with bmc, its sufficient to check the first hardware.
if p.catalogue.TotalHardware() > 0 && p.catalogue.AllHardware()[0].Spec.BMCRef != nil {
// Waiting to ensure all the new and exisiting baseboardmanagement connections are valid.
err = p.providerKubectlClient.WaitForRufioMachines(ctx, cluster, "5m", "Contactable", constants.EksaSystemNamespace)
if err != nil {
return fmt.Errorf("waiting for baseboard management to be contactable: %v", err)
}
}

Expand Down