Skip to content

CLOUDP-321942: Enable support to GCP resources at Atlas Gov #2367

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 1 commit into from
Jun 10, 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
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ GOMOD_SHA := $(shell git ls-files -s go.mod | awk '{print $$1" "$$2" "$$4}')
LICENSES_GOMOD_SHA_FILE := .licenses-gomod.sha256
GOMOD_LICENSES_SHA := $(shell cat $(LICENSES_GOMOD_SHA_FILE))

OPERATOR_NAMESPACE=atlas-operator
OPERATOR_POD_NAME=mongodb-atlas-operator
RUN_YAML= # Set to the YAML to run when calling make run
RUN_LOG_LEVEL ?= debug
Expand Down
4 changes: 3 additions & 1 deletion internal/controller/atlas/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ func (p *ProductionProvider) IsResourceSupported(resource api.AtlasCustomResourc
*akov2.AtlasSearchIndexConfig,
*akov2.AtlasBackupCompliancePolicy,
*akov2.AtlasFederatedAuth,
*akov2.AtlasPrivateEndpoint:
*akov2.AtlasPrivateEndpoint,
*akov2.AtlasNetworkContainer,
*akov2.AtlasNetworkPeering:
return true
case *akov2.AtlasDataFederation,
*akov2.AtlasStreamInstance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (r *AtlasDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Requ
return r.terminate(workflowCtx, workflow.AtlasAPIAccessNotConfigured, err)
}

if err := validate.AtlasDeployment(atlasDeployment, r.AtlasProvider.IsCloudGov(), atlasProject.RegionUsageRestrictions); err != nil {
if err := validate.AtlasDeployment(atlasDeployment); err != nil {
result = workflow.Terminate(workflow.Internal, err)
workflowCtx.SetConditionFromResult(api.ValidationSucceeded, result)
return result.ReconcileResult(), nil
Expand Down
25 changes: 3 additions & 22 deletions internal/controller/validate/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ func deploymentSpecMask(atlasDeployment *akov2.AtlasDeployment) int {
return mask
}

func AtlasDeployment(atlasDeployment *akov2.AtlasDeployment, isGov bool, regionUsageRestrictions string) error {
func AtlasDeployment(atlasDeployment *akov2.AtlasDeployment) error {
var err error
var tagsSpec []*akov2.TagSpec
switch deploymentSpecMask(atlasDeployment) {
case 0:
return errors.New("expected exactly one of spec.deploymentSpec or spec.serverlessSpec or spec.flexSpec to be present, but none were")
case DeploymentSet:
tagsSpec = atlasDeployment.Spec.DeploymentSpec.Tags
err = regularDeployment(atlasDeployment.Spec.DeploymentSpec, isGov, regionUsageRestrictions)
err = regularDeployment(atlasDeployment.Spec.DeploymentSpec)
case ServerlessSet:
tagsSpec = atlasDeployment.Spec.ServerlessSpec.Tags
err = serverlessDeployment(atlasDeployment.Spec.ServerlessSpec)
Expand All @@ -75,13 +75,7 @@ func AtlasDeployment(atlasDeployment *akov2.AtlasDeployment, isGov bool, regionU
return nil
}

func regularDeployment(spec *akov2.AdvancedDeploymentSpec, isGov bool, regionUsageRestrictions string) error {
if isGov {
if err := deploymentForGov(spec, regionUsageRestrictions); err != nil {
return err
}
}

func regularDeployment(spec *akov2.AdvancedDeploymentSpec) error {
var autoscaling akov2.AdvancedAutoScalingSpec
var instanceSize string
for _, replicaSetSpec := range spec.ReplicationSpecs {
Expand Down Expand Up @@ -254,19 +248,6 @@ func advancedInstanceSizeInRange(currentInstanceSize, minInstanceSize, maxInstan
return nil
}

func deploymentForGov(spec *akov2.AdvancedDeploymentSpec, regionUsageRestrictions string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted code is the best code 😍

for _, replication := range spec.ReplicationSpecs {
for _, region := range replication.RegionConfigs {
regionErr := validCloudGovRegion(regionUsageRestrictions, region.RegionName)
if regionErr != nil {
return fmt.Errorf("deployment in atlas for government support a restricted set of regions: %w", regionErr)
}
}
}

return nil
}

func serverlessDeployment(spec *akov2.ServerlessSpec) error {
supportedProviders := provider.SupportedProviders()
switch {
Expand Down
Loading
Loading