Skip to content

CLOUDP-333238: add configServerManagementMode to AtlasDeployment #2538

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions api/v1/atlasdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ type AdvancedDeploymentSpec struct {
// A list of atlas search indexes configuration for the current deployment
// +optional
SearchIndexes []SearchIndex `json:"searchIndexes,omitempty"`
// Config Server Management Mode for creating or updating a sharded cluster.
// +kubebuilder:validation:Enum=ATLAS_MANAGED;FIXED_TO_DEDICATED
// +optional
ConfigServerManagementMode string `json:"configServerManagementMode,omitempty"`
}

// ToAtlas converts the AdvancedDeploymentSpec to native Atlas client ToAtlas format.
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/atlas.mongodb.com_atlasdeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ spec:
- SHARDED
- GEOSHARDED
type: string
configServerManagementMode:
description: Config Server Management Mode for creating or updating
a sharded cluster.
enum:
- ATLAS_MANAGED
- FIXED_TO_DEDICATED
type: string
customZoneMapping:
items:
properties:
Expand Down
5 changes: 5 additions & 0 deletions internal/translation/deployment/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func ComputeChanges(desired, current *Cluster) (*Cluster, bool) {
VersionReleaseSystem: desired.VersionReleaseSystem,
BackupEnabled: desired.BackupEnabled,
EncryptionAtRestProvider: desired.EncryptionAtRestProvider,
ConfigServerManagementMode: desired.ConfigServerManagementMode,
BiConnector: desired.BiConnector,
PitEnabled: desired.PitEnabled,
RootCertType: desired.RootCertType,
Expand Down Expand Up @@ -145,6 +146,10 @@ func specAreEqual(desired, current *Cluster) bool {
return false
}

if desired.ConfigServerManagementMode != "" && !areEqual(&desired.ConfigServerManagementMode, &current.ConfigServerManagementMode) {
return false
}

if desired.MongoDBMajorVersion != "" && !areEqual(&desired.MongoDBMajorVersion, &current.MongoDBMajorVersion) {
return false
}
Expand Down
12 changes: 12 additions & 0 deletions internal/translation/deployment/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,18 @@ func TestSpecAreEqual(t *testing.T) {
EncryptionAtRestProvider: pointer.MakePtr("NONE"),
},
},
"should return false when config server management are different": {
ako: &akov2.AtlasDeployment{
Spec: akov2.AtlasDeploymentSpec{
DeploymentSpec: &akov2.AdvancedDeploymentSpec{
ConfigServerManagementMode: "ATLAS_MANAGED",
},
},
},
atlas: &admin.ClusterDescription20240805{
ConfigServerManagementMode: pointer.MakePtr("FIXED_TO_DEDICATED"),
},
},
"should return false when mongodb version are different": {
ako: &akov2.AtlasDeployment{
Spec: akov2.AtlasDeploymentSpec{
Expand Down
4 changes: 4 additions & 0 deletions internal/translation/deployment/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ func clusterFromAtlas(clusterDesc *admin.ClusterDescription20240805) *Cluster {
TerminationProtectionEnabled: clusterDesc.GetTerminationProtectionEnabled(),
SearchNodes: nil,
SearchIndexes: nil,
ConfigServerManagementMode: clusterDesc.GetConfigServerManagementMode(),
},
}
normalizeClusterDeployment(cluster)
Expand Down Expand Up @@ -625,6 +626,7 @@ func clusterCreateToAtlas(cluster *Cluster) *admin.ClusterDescription20240805 {
RootCertType: pointer.MakePtrOrNil(cluster.RootCertType),
Tags: tag.ToAtlas(cluster.Tags),
TerminationProtectionEnabled: pointer.MakePtrOrNil(cluster.TerminationProtectionEnabled),
ConfigServerManagementMode: pointer.MakePtrOrNil(cluster.ConfigServerManagementMode),
}
}

Expand All @@ -643,6 +645,7 @@ func clusterUpdateToAtlas(cluster *Cluster) *admin.ClusterDescription20240805 {
RootCertType: pointer.MakePtrOrNil(cluster.RootCertType),
Tags: tag.ToAtlas(cluster.Tags),
TerminationProtectionEnabled: pointer.MakePtrOrNil(cluster.TerminationProtectionEnabled),
ConfigServerManagementMode: pointer.MakePtrOrNil(cluster.ConfigServerManagementMode),
}
}

Expand Down Expand Up @@ -1293,5 +1296,6 @@ func flexUpgradeToAtlas(cluster *Cluster) *admin.AtlasTenantClusterUpgradeReques
RootCertType: pointer.MakePtrOrNil(spec.RootCertType),
Tags: tag.ToAtlas(spec.Tags),
TerminationProtectionEnabled: pointer.MakePtrOrNil(spec.TerminationProtectionEnabled),
ConfigServerManagementMode: pointer.MakePtrOrNil(spec.ConfigServerManagementMode),
}
}
3 changes: 3 additions & 0 deletions internal/translation/deployment/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func TestNewDeployment(t *testing.T) {
},
},
TerminationProtectionEnabled: true,
ConfigServerManagementMode: "ATLAS_MANAGED",
Labels: []common.LabelSpec{
{
Key: "name",
Expand Down Expand Up @@ -213,6 +214,7 @@ func TestNewDeployment(t *testing.T) {
},
},
TerminationProtectionEnabled: true,
ConfigServerManagementMode: "ATLAS_MANAGED",
Labels: []common.LabelSpec{
{
Key: "name",
Expand Down Expand Up @@ -268,6 +270,7 @@ func TestNewDeployment(t *testing.T) {
},
},
TerminationProtectionEnabled: true,
ConfigServerManagementMode: "ATLAS_MANAGED",
Labels: []common.LabelSpec{
{
Key: "name",
Expand Down
Loading