Skip to content

Commit

Permalink
provide rotatorconfig when resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed Oct 24, 2022
1 parent e96aeb8 commit 574b8d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions internal/provisioner/kops_provisioner_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,16 @@ func (provisioner *KopsProvisioner) ResizeCluster(cluster *model.Cluster, awsCli
return err
}

if cluster.ProvisionerMetadataKops.RotatorRequest.Config != nil {
if *cluster.ProvisionerMetadataKops.RotatorRequest.Config.UseRotator {
logger.Info("Using node rotator for node resize")
err = provisioner.RotateClusterNodes(cluster)
if err != nil {
return err
}
}
}

err = kops.RollingUpdateCluster(kopsMetadata.Name)
if err != nil {
return err
Expand Down
18 changes: 15 additions & 3 deletions model/cluster_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,10 @@ func NewUpgradeClusterRequestFromReader(reader io.Reader) (*PatchUpgradeClusterR

// PatchClusterSizeRequest specifies the parameters for resizing a cluster.
type PatchClusterSizeRequest struct {
NodeInstanceType *string `json:"node-instance-type,omitempty"`
NodeMinCount *int64 `json:"node-min-count,omitempty"`
NodeMaxCount *int64 `json:"node-max-count,omitempty"`
NodeInstanceType *string `json:"node-instance-type,omitempty"`
NodeMinCount *int64 `json:"node-min-count,omitempty"`
NodeMaxCount *int64 `json:"node-max-count,omitempty"`
RotatorConfig *RotatorConfig `json:"rotatorConfig,omitempty"`
}

// Validate validates the values of a PatchClusterSizeRequest.
Expand All @@ -311,6 +312,12 @@ func (p *PatchClusterSizeRequest) Validate() error {
return errors.Errorf("node max count (%d) can't be less than min count (%d)", *p.NodeMaxCount, *p.NodeMinCount)
}

if p.RotatorConfig != nil {
if err := p.RotatorConfig.Validate(); err != nil {
return err
}
}

return nil
}

Expand All @@ -332,8 +339,13 @@ func (p *PatchClusterSizeRequest) Apply(metadata *KopsMetadata) bool {
changes.NodeMaxCount = *p.NodeMaxCount
}

if metadata.RotatorRequest == nil {
metadata.RotatorRequest = &RotatorMetadata{}
}

if applied {
metadata.ChangeRequest = changes
metadata.RotatorRequest.Config = p.RotatorConfig
}

return applied
Expand Down

0 comments on commit 574b8d0

Please sign in to comment.