Skip to content

Commit

Permalink
Block upgrade rollout strategy configuration for snow provider (aws#4313
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ptrivedi authored Dec 7, 2022
1 parent d796af8 commit 8b54e9d
Show file tree
Hide file tree
Showing 2 changed files with 301 additions and 93 deletions.
21 changes: 21 additions & 0 deletions pkg/providers/snow/snow.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ func (p *SnowProvider) Name() string {
}

func (p *SnowProvider) SetupAndValidateCreateCluster(ctx context.Context, clusterSpec *cluster.Spec) error {
if err := p.validateUpgradeRolloutStrategy(clusterSpec); err != nil {
return fmt.Errorf("failed setup and validations: %v", err)
}
if err := p.configManager.SetDefaultsAndValidate(ctx, clusterSpec.Config); err != nil {
return fmt.Errorf("setting defaults and validate snow config: %v", err)
}
Expand All @@ -83,13 +86,19 @@ func (p *SnowProvider) SetupAndValidateCreateCluster(ctx context.Context, cluste
}

func (p *SnowProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error {
if err := p.validateUpgradeRolloutStrategy(clusterSpec); err != nil {
return fmt.Errorf("failed setup and validations: %v", err)
}
if err := p.configManager.SetDefaultsAndValidate(ctx, clusterSpec.Config); err != nil {
return fmt.Errorf("setting defaults and validate snow config: %v", err)
}
return nil
}

func (p *SnowProvider) SetupAndValidateDeleteCluster(ctx context.Context, _ *types.Cluster, clusterSpec *cluster.Spec) error {
if err := p.validateUpgradeRolloutStrategy(clusterSpec); err != nil {
return fmt.Errorf("failed setup and validations: %v", err)
}
if err := SetupEksaCredentialsSecret(clusterSpec.Config); err != nil {
return fmt.Errorf("setting up credentials: %v", err)
}
Expand Down Expand Up @@ -271,6 +280,18 @@ func machineConfigsEqual(new, old map[string]*v1alpha1.SnowMachineConfig) bool {
return true
}

func (p *SnowProvider) validateUpgradeRolloutStrategy(clusterSpec *cluster.Spec) error {
if clusterSpec.Cluster.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy != nil {
return fmt.Errorf("Upgrade rollout strategy customization is not supported for snow provider")
}
for _, workerNodeGroupConfiguration := range clusterSpec.Cluster.Spec.WorkerNodeGroupConfigurations {
if workerNodeGroupConfiguration.UpgradeRolloutStrategy != nil {
return fmt.Errorf("Upgrade rollout strategy customization is not supported for snow provider")
}
}
return nil
}

func (p *SnowProvider) UpgradeNeeded(ctx context.Context, newSpec, oldSpec *cluster.Spec, _ *types.Cluster) (bool, error) {
return !bundleImagesEqual(newSpec.VersionsBundle.Snow, oldSpec.VersionsBundle.Snow) ||
!machineConfigsEqual(newSpec.SnowMachineConfigs, oldSpec.SnowMachineConfigs), nil
Expand Down
Loading

0 comments on commit 8b54e9d

Please sign in to comment.