Skip to content

CLOUDP-320196: fix skew detection for disabled compute autoscaling #2347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions internal/controller/atlasdeployment/advanced_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ func TestHandleAdvancedDeployment(t *testing.T) {
},
},
},
//nolint:dupl
deploymentInAtlas: &deployment.Cluster{
ProjectID: "project-id",
State: "IDLE",
Expand All @@ -577,6 +578,14 @@ func TestHandleAdvancedDeployment(t *testing.T) {
InstanceSize: "M10",
NodeCount: pointer.MakePtr(3),
},
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
},
DiskGB: &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
},
},
},
},
},
Expand Down Expand Up @@ -634,6 +643,7 @@ func TestHandleAdvancedDeployment(t *testing.T) {
},
},
},
//nolint:dupl
deploymentInAtlas: &deployment.Cluster{
ProjectID: "project-id",
State: "IDLE",
Expand All @@ -660,6 +670,14 @@ func TestHandleAdvancedDeployment(t *testing.T) {
InstanceSize: "M10",
NodeCount: pointer.MakePtr(3),
},
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
},
DiskGB: &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
},
},
},
},
},
Expand Down
17 changes: 15 additions & 2 deletions internal/translation/deployment/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,21 @@ func normalizeRegionConfigs(regionConfigs []*akov2.AdvancedRegionConfig, isTenan
regionConfig.AutoScaling.Compute.Enabled == nil || !*regionConfig.AutoScaling.Compute.Enabled
diskUnsetOrDisabled := regionConfig.AutoScaling == nil || regionConfig.AutoScaling.DiskGB == nil ||
regionConfig.AutoScaling.DiskGB.Enabled == nil || !*regionConfig.AutoScaling.DiskGB.Enabled
if computeUnsetOrDisabled && diskUnsetOrDisabled {
regionConfig.AutoScaling = nil

if regionConfig.AutoScaling == nil {
regionConfig.AutoScaling = &akov2.AdvancedAutoScalingSpec{}
}

if computeUnsetOrDisabled {
regionConfig.AutoScaling.Compute = &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
}
}

if diskUnsetOrDisabled {
regionConfig.AutoScaling.DiskGB = &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
}
}
}
}
Expand Down
92 changes: 92 additions & 0 deletions internal/translation/deployment/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ func TestNewDeployment(t *testing.T) {
InstanceSize: "M10",
NodeCount: pointer.MakePtr(3),
},
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
},
DiskGB: &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
},
},
},
},
},
Expand Down Expand Up @@ -547,6 +555,14 @@ func TestNormalizeClusterDeployment(t *testing.T) {
AnalyticsSpecs: nil,
ElectableSpecs: nil,
ReadOnlySpecs: nil,
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
},
DiskGB: &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
},
},
},
},
},
Expand Down Expand Up @@ -591,6 +607,74 @@ func TestNormalizeClusterDeployment(t *testing.T) {
AnalyticsSpecs: nil,
ElectableSpecs: nil,
ReadOnlySpecs: nil,
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
},
DiskGB: &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
},
},
},
},
},
},
},
},
},
"regionconfig specs with autoscaling": {
deployment: &Cluster{
AdvancedDeploymentSpec: &akov2.AdvancedDeploymentSpec{
ReplicationSpecs: []*akov2.AdvancedReplicationSpec{
{
RegionConfigs: []*akov2.AdvancedRegionConfig{
{
AnalyticsSpecs: &akov2.Specs{},
ElectableSpecs: &akov2.Specs{},
ReadOnlySpecs: &akov2.Specs{},
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
ScaleDownEnabled: pointer.MakePtr(false),
MinInstanceSize: "M10",
MaxInstanceSize: "M10",
},
},
},
},
},
},
},
},
expected: &Cluster{
AdvancedDeploymentSpec: &akov2.AdvancedDeploymentSpec{
ClusterType: "REPLICASET",
EncryptionAtRestProvider: "NONE",
MongoDBMajorVersion: "7.0",
VersionReleaseSystem: "LTS",
Paused: pointer.MakePtr(false),
PitEnabled: pointer.MakePtr(false),
RootCertType: "ISRGROOTX1",
BackupEnabled: pointer.MakePtr(false),
Tags: []*akov2.TagSpec{},

ReplicationSpecs: []*akov2.AdvancedReplicationSpec{
{
NumShards: 1,
ZoneName: "Zone 1",
RegionConfigs: []*akov2.AdvancedRegionConfig{
{
AnalyticsSpecs: nil,
ElectableSpecs: nil,
ReadOnlySpecs: nil,
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
},
DiskGB: &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
},
},
},
},
},
Expand Down Expand Up @@ -690,6 +774,14 @@ func TestNormalizeClusterDeployment(t *testing.T) {
InstanceSize: "M10",
NodeCount: pointer.MakePtr(3),
},
AutoScaling: &akov2.AdvancedAutoScalingSpec{
Compute: &akov2.ComputeSpec{
Enabled: pointer.MakePtr(false),
},
DiskGB: &akov2.DiskGB{
Enabled: pointer.MakePtr(false),
},
},
},
},
},
Expand Down
Loading