Skip to content

Commit

Permalink
remove setup upgrade cluster validations
Browse files Browse the repository at this point in the history
  • Loading branch information
cxbrowne1207 committed Feb 14, 2024
1 parent 2e7f5ba commit 2f0fb12
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 3 deletions.
9 changes: 9 additions & 0 deletions pkg/providers/cloudstack/cloudstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,15 @@ func (p *cloudstackProvider) SetupAndValidateDeleteCluster(ctx context.Context,
return nil
}

// SetupUpgradeManagementComponents performs necessary setup for upgrade management components operation.
func (p *cloudstackProvider) SetupUpgradeManagementComponents(ctx context.Context, _ *cluster.Spec) error {
err := p.validateEnv(ctx)
if err != nil {
return fmt.Errorf("validating environment variables: %v", err)
}
return nil
}

func needsNewControlPlaneTemplate(oldSpec, newSpec *cluster.Spec, oldCsmc, newCsmc *v1alpha1.CloudStackMachineConfig, log logr.Logger) bool {
// Another option is to generate MachineTemplates based on the old and new eksa spec,
// remove the name field and compare them with DeepEqual
Expand Down
5 changes: 5 additions & 0 deletions pkg/providers/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types.
return nil
}

// SetupUpgradeManagementComponents performs necessary setup for upgrade management components operation.
func (p *Provider) SetupUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error {
return nil
}

// UpdateSecrets is a no-op. It implements providers.Provider.
func (p *Provider) UpdateSecrets(ctx context.Context, cluster *types.Cluster, _ *cluster.Spec) error {
// Not implemented
Expand Down
14 changes: 14 additions & 0 deletions pkg/providers/mocks/providers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/providers/nutanix/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,19 @@ func (p *Provider) SetupAndValidateDeleteCluster(ctx context.Context, cluster *t

// SetupAndValidateUpgradeCluster - Performs necessary setup and validations for upgrade cluster operation.
func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error {
if err := p.SetupUpgradeManagementComponents(ctx, clusterSpec); err != nil {
return fmt.Errorf("failed setup and validations: %v", err)
}

if err := p.validator.validateUpgradeRolloutStrategy(clusterSpec); err != nil {
return fmt.Errorf("failed setup and validations: %v", err)
}

return nil
}

// SetupUpgradeManagementComponents performs necessary setup for upgrade management components operation.
func (p *Provider) SetupUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error {
// TODO(nutanix): Add validations when this is supported
if err := setupEnvVars(p.datacenterConfig); err != nil {
return fmt.Errorf("failed setup and validations: %v", err)
Expand Down
1 change: 1 addition & 0 deletions pkg/providers/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Provider interface {
SetupAndValidateCreateCluster(ctx context.Context, clusterSpec *cluster.Spec) error
SetupAndValidateDeleteCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error
SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, currentSpec *cluster.Spec) error
SetupUpgradeManagementComponents(ctx context.Context, clusterSpec *cluster.Spec) error
UpdateSecrets(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error
GenerateCAPISpecForCreate(ctx context.Context, managementCluster *types.Cluster, clusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error)
GenerateCAPISpecForUpgrade(ctx context.Context, bootstrapCluster, workloadCluster *types.Cluster, currrentSpec, newClusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error)
Expand Down
5 changes: 5 additions & 0 deletions pkg/providers/snow/snow.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ func (p *SnowProvider) SetupAndValidateUpgradeCluster(ctx context.Context, clust
return nil
}

// SetupUpgradeManagementComponents performs necessary setup for upgrade management components operation.
func (p *SnowProvider) SetupUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error {
return nil
}

func (p *SnowProvider) SetupAndValidateDeleteCluster(ctx context.Context, _ *types.Cluster, clusterSpec *cluster.Spec) error {
if err := SetupEksaCredentialsSecret(clusterSpec.Config); err != nil {
return fmt.Errorf("setting up credentials: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions pkg/providers/tinkerbell/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *
return nil
}

// SetupUpgradeManagementComponents performs necessary setup for upgrade management components operation.
func (p *Provider) SetupUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error {
return nil
}

func (p *Provider) validateAvailableHardwareForUpgrade(ctx context.Context, currentSpec, newClusterSpec *cluster.Spec) (err error) {
clusterSpecValidator := NewClusterSpecValidator(
HardwareSatisfiesOnlyOneSelectorAssertion(p.catalogue),
Expand Down
11 changes: 10 additions & 1 deletion pkg/providers/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (p *vsphereProvider) SetupAndValidateCreateCluster(ctx context.Context, clu
}

func (p *vsphereProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error {
if err := SetupEnvVars(clusterSpec.VSphereDatacenter); err != nil {
if err := p.SetupUpgradeManagementComponents(ctx, clusterSpec); err != nil {
return fmt.Errorf("failed setup and validations: %v", err)
}

Expand Down Expand Up @@ -424,6 +424,15 @@ func (p *vsphereProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cl
return nil
}

// SetupUpgradeManagementComponents performs necessary setup for upgrade management components operation.
func (p *vsphereProvider) SetupUpgradeManagementComponents(ctx context.Context, clusterSpec *cluster.Spec) error {
if err := SetupEnvVars(clusterSpec.VSphereDatacenter); err != nil {
return fmt.Errorf("failed environment variable setup: %v", err)
}

return nil
}

func (p *vsphereProvider) validateMachineConfigsNameUniqueness(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error {
prevSpec, err := p.providerKubectlClient.GetEksaCluster(ctx, cluster, clusterSpec.Cluster.GetName())
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/workflows/management/upgrade_management_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func (s *setupAndValidateMC) Run(ctx context.Context, commandContext *task.Comma
runner.Register(
func() *validations.ValidationResult {
return &validations.ValidationResult{
Name: fmt.Sprintf("%s provider validation", commandContext.Provider.Name()),
Err: commandContext.Provider.SetupAndValidateUpgradeCluster(ctx, commandContext.ManagementCluster, commandContext.ClusterSpec, commandContext.CurrentClusterSpec),
Name: fmt.Sprintf("%s provider setup", commandContext.Provider.Name()),
Err: commandContext.Provider.SetupUpgradeManagementComponents(ctx, commandContext.ClusterSpec),
}
},
)
Expand Down
26 changes: 26 additions & 0 deletions test/e2e/tinkerbell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1478,3 +1478,29 @@ func TestTinkerbellSingleNode127To128UbuntuManagementCPUpgradeAPI(t *testing.T)
provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil),
)
}

func TestTinkerbellKubernetes128UpgradeManagementComponents(t *testing.T) {
release := latestMinorRelease(t)
provider := framework.NewTinkerbell(t, framework.WithUbuntu128Tinkerbell())
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
)
// create cluster with old eksa
test.GenerateClusterConfigForVersion(release.Version, framework.ExecuteWithEksaRelease(release))
test.UpdateClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube128),
api.WithControlPlaneCount(1),
api.WithWorkerNodeCount(1),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil),
)

test.CreateCluster(framework.ExecuteWithEksaRelease(release))
// upgrade management-components with new eksa
test.RunEKSA([]string{"upgrade", "management-components", "-f", test.ClusterConfigLocation, "-v", "99"})
test.DeleteCluster()
}
24 changes: 24 additions & 0 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,30 @@ func TestVSphereKubernetes128UbuntuInPlaceWorkerScaleDown2To1(t *testing.T) {
)
}

func TestVSphereKubernetes128UpgradeManagementComponents(t *testing.T) {
release := latestMinorRelease(t)
provider := framework.NewVSphere(t, framework.WithUbuntu128())
test := framework.NewClusterE2ETest(
t,
provider,
)
// create cluster with old eksa
test.GenerateClusterConfigForVersion(release.Version, framework.ExecuteWithEksaRelease(release))
test.UpdateClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube128),
api.WithControlPlaneCount(1),
api.WithWorkerNodeCount(1),
),
provider.WithKubeVersionAndOSForRelease(v1alpha1.Kube128, framework.Ubuntu2004, release),
)

test.CreateCluster(framework.ExecuteWithEksaRelease(release))
// upgrade management-components with new eksa
test.RunEKSA([]string{"upgrade", "management-components", "-f", test.ClusterConfigLocation, "-v", "99"})
test.DeleteCluster()
}

// Workload API
func TestVSphereMulticlusterWorkloadClusterAPI(t *testing.T) {
vsphere := framework.NewVSphere(t)
Expand Down

0 comments on commit 2f0fb12

Please sign in to comment.