Skip to content

Commit

Permalink
Improved determination on whether to use disk auto-expansion.
Browse files Browse the repository at this point in the history
  • Loading branch information
brett19 committed Sep 14, 2023
1 parent 69300a4 commit 4733c74
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 21 deletions.
28 changes: 16 additions & 12 deletions deployment/clouddeploy/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ type NewClusterOptions struct {
func (p *Deployer) buildCreateSpecs(
ctx context.Context,
cloudProvider string,
clusterVersion string,
diskAutoExpansionEnabled bool,
nodeGrps []*clusterdef.NodeGroup,
) ([]capellacontrol.CreateClusterRequest_Spec, error) {
nodeProvider := ""
Expand Down Expand Up @@ -284,11 +284,6 @@ func (p *Deployer) buildCreateSpecs(
return nil, errors.Wrap(err, "failed to generate ns server services list")
}

diskAutoScalingEnabled := true
if clusterVersion == "7.1" {
diskAutoScalingEnabled = false
}

specs = append(specs, capellacontrol.CreateClusterRequest_Spec{
Compute: instanceType,
Count: nodeGroup.Count,
Expand All @@ -298,7 +293,7 @@ func (p *Deployer) buildCreateSpecs(
Iops: diskIops,
},
DiskAutoScaling: capellacontrol.CreateClusterRequest_Spec_DiskScaling{
Enabled: diskAutoScalingEnabled,
Enabled: diskAutoExpansionEnabled,
},
Provider: nodeProvider,
Services: nsServices,
Expand All @@ -311,10 +306,10 @@ func (p *Deployer) buildCreateSpecs(
func (p *Deployer) buildModifySpecs(
ctx context.Context,
cloudProvider string,
clusterVersion string,
diskAutoExpansionEnabled bool,
nodeGrps []*clusterdef.NodeGroup,
) ([]capellacontrol.UpdateClusterSpecsRequest_Spec, error) {
createSpecs, err := p.buildCreateSpecs(ctx, cloudProvider, clusterVersion, nodeGrps)
createSpecs, err := p.buildCreateSpecs(ctx, cloudProvider, diskAutoExpansionEnabled, nodeGrps)
if err != nil {
return nil, errors.Wrap(err, "failed to build the create specs")
}
Expand Down Expand Up @@ -437,14 +432,16 @@ func (p *Deployer) NewCluster(ctx context.Context, def *clusterdef.Cluster) (dep
clusterCidr = deploymentOpts.SuggestedCidr
}

diskAutoExpansionEnabled := deploymentOpts.Provider.AutoExpansion.Enabled

p.logger.Debug("creating a new cloud cluster")

clusterName := fmt.Sprintf("cbdc2_%s", clusterID)

specs, err := p.buildCreateSpecs(
ctx,
cloudProvider,
clusterVersion,
diskAutoExpansionEnabled,
def.NodeGroups)
if err != nil {
return nil, errors.Wrap(err, "failed to build cluster specs")
Expand Down Expand Up @@ -513,12 +510,19 @@ func (d *Deployer) ModifyCluster(ctx context.Context, clusterID string, def *clu
cloudProjectID := clusterInfo.Cluster.Project.Id
cloudClusterID := clusterInfo.Cluster.Id
cloudProvider := clusterInfo.Cluster.Provider.Name
clusterVersion := clusterInfo.Cluster.Config.Version

// we use the existing nodes to infer whether to enable auto-expansion
diskAutoExpansionEnabled := false
for _, svc := range clusterInfo.Cluster.Services {
if svc.DiskAutoScaling.Enabled {
diskAutoExpansionEnabled = true
}
}

newSpecs, err := d.buildModifySpecs(
ctx,
cloudProvider,
clusterVersion,
diskAutoExpansionEnabled,
def.NodeGroups)
if err != nil {
return errors.Wrap(err, "failed to build cluster specs")
Expand Down
62 changes: 53 additions & 9 deletions utils/capellacontrol/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,15 @@ type ClusterInfo struct {
ModifiedByUserID string `json:"modifiedByUserID"`
Name string `json:"name"`
// Package
PlaygroundDisabled bool `json:"playgroundDisabled"`
Project ClusterInfo_Project `json:"project"`
Provider ClusterInfo_Provider `json:"provider"`
// Services
Status ClusterInfo_Status `json:"status"`
TenantId string `json:"tenantId"`
UpsertedAt time.Time `json:"upsertedAt"`
UpsertedUserID string `json:"upsertedUserID"`
Version int `json:"version"`
PlaygroundDisabled bool `json:"playgroundDisabled"`
Project ClusterInfo_Project `json:"project"`
Provider ClusterInfo_Provider `json:"provider"`
Services []ClusterInfo_Service `json:"services"`
Status ClusterInfo_Status `json:"status"`
TenantId string `json:"tenantId"`
UpsertedAt time.Time `json:"upsertedAt"`
UpsertedUserID string `json:"upsertedUserID"`
Version int `json:"version"`
}

type ClusterInfo_Config struct {
Expand All @@ -395,6 +395,36 @@ type ClusterInfo_Provider struct {
Region string `json:"region"`
}

type ClusterInfo_Service struct {
Compute ClusterInfo_Service_Compute `json:"compute"`
Count int `json:"count"`
Disk ClusterInfo_Service_Disk `json:"disk"`
DiskAutoScaling ClusterInfo_Service_DiskScaling `json:"diskAutoScaling"`
Services []ClusterInfo_Service_Service `json:"services"`
}

type ClusterInfo_Service_Compute struct {
Type string `json:"type"`
MemoryInGB int `json:"memoryInGb"`
Cpu int `json:"cpu"`
}

type ClusterInfo_Service_Disk struct {
Type string `json:"type"`
SizeInGb int `json:"sizeInGb"`
Iops int `json:"iops"`
ThroughputMBPS int `json:"throughputMbps"`
}

type ClusterInfo_Service_DiskScaling struct {
Enabled bool `json:"enabled"`
}

type ClusterInfo_Service_Service struct {
Type string `json:"type"`
MemoryAllocationInMB int `json:"memoryAllocationInMb"`
}

type ClusterInfo_Status struct {
State string `json:"state"`
}
Expand Down Expand Up @@ -587,10 +617,24 @@ type GetProviderDeploymentOptionsResponse struct {
// deliveryMethods
// plans
// projects
Provider GetProviderDeploymentOptionsResponse_Provider `json:"provider"`
ServerVersions GetProviderDeploymentOptionsResponse_ServerVersions `json:"serverVersions"`
SuggestedCidr string `json:"suggestedCidr"`
}

type GetProviderDeploymentOptionsResponse_Provider struct {
AutoExpansion GetProviderDeploymentOptionsResponse_Provider_AutoExpansion `json:"autoExpansion"`
DisplayName string `json:"displayName"`
// eligibility
Key string `json:"key"`
// regions
// services
}

type GetProviderDeploymentOptionsResponse_Provider_AutoExpansion struct {
Enabled bool `json:"enabled"`
}

type GetProviderDeploymentOptionsResponse_ServerVersions struct {
DefaultVersion string `json:"defaultVersion"`
Versions []string `json:"versions"`
Expand Down

0 comments on commit 4733c74

Please sign in to comment.