Skip to content

Commit

Permalink
Adding logic to apply new hardware on tink upgrades (#8295)
Browse files Browse the repository at this point in the history
Co-authored-by: Aravind Ramalingam <ramaliar@amazon.com>
  • Loading branch information
eks-distro-pr-bot and pokearu authored Jun 12, 2024
1 parent 0ad284f commit f5b4741
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
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

0 comments on commit f5b4741

Please sign in to comment.