Skip to content

Commit 77d057e

Browse files
authored
enable support to GCP resources at Atlas Gov (#2367)
1 parent 8e07deb commit 77d057e

File tree

7 files changed

+30
-437
lines changed

7 files changed

+30
-437
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ GOMOD_SHA := $(shell git ls-files -s go.mod | awk '{print $$1" "$$2" "$$4}')
122122
LICENSES_GOMOD_SHA_FILE := .licenses-gomod.sha256
123123
GOMOD_LICENSES_SHA := $(shell cat $(LICENSES_GOMOD_SHA_FILE))
124124

125-
OPERATOR_NAMESPACE=atlas-operator
126125
OPERATOR_POD_NAME=mongodb-atlas-operator
127126
RUN_YAML= # Set to the YAML to run when calling make run
128127
RUN_LOG_LEVEL ?= debug

internal/controller/atlas/provider.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ func (p *ProductionProvider) IsResourceSupported(resource api.AtlasCustomResourc
105105
*akov2.AtlasSearchIndexConfig,
106106
*akov2.AtlasBackupCompliancePolicy,
107107
*akov2.AtlasFederatedAuth,
108-
*akov2.AtlasPrivateEndpoint:
108+
*akov2.AtlasPrivateEndpoint,
109+
*akov2.AtlasNetworkContainer,
110+
*akov2.AtlasNetworkPeering:
109111
return true
110112
case *akov2.AtlasDataFederation,
111113
*akov2.AtlasStreamInstance,

internal/controller/atlasdeployment/atlasdeployment_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (r *AtlasDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Requ
150150
return r.terminate(workflowCtx, workflow.AtlasAPIAccessNotConfigured, err)
151151
}
152152

153-
if err := validate.AtlasDeployment(atlasDeployment, r.AtlasProvider.IsCloudGov(), atlasProject.RegionUsageRestrictions); err != nil {
153+
if err := validate.AtlasDeployment(atlasDeployment); err != nil {
154154
result = workflow.Terminate(workflow.Internal, err)
155155
workflowCtx.SetConditionFromResult(api.ValidationSucceeded, result)
156156
return result.ReconcileResult(), nil

internal/controller/validate/deployment.go

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ func deploymentSpecMask(atlasDeployment *akov2.AtlasDeployment) int {
4545
return mask
4646
}
4747

48-
func AtlasDeployment(atlasDeployment *akov2.AtlasDeployment, isGov bool, regionUsageRestrictions string) error {
48+
func AtlasDeployment(atlasDeployment *akov2.AtlasDeployment) error {
4949
var err error
5050
var tagsSpec []*akov2.TagSpec
5151
switch deploymentSpecMask(atlasDeployment) {
5252
case 0:
5353
return errors.New("expected exactly one of spec.deploymentSpec or spec.serverlessSpec or spec.flexSpec to be present, but none were")
5454
case DeploymentSet:
5555
tagsSpec = atlasDeployment.Spec.DeploymentSpec.Tags
56-
err = regularDeployment(atlasDeployment.Spec.DeploymentSpec, isGov, regionUsageRestrictions)
56+
err = regularDeployment(atlasDeployment.Spec.DeploymentSpec)
5757
case ServerlessSet:
5858
tagsSpec = atlasDeployment.Spec.ServerlessSpec.Tags
5959
err = serverlessDeployment(atlasDeployment.Spec.ServerlessSpec)
@@ -75,13 +75,7 @@ func AtlasDeployment(atlasDeployment *akov2.AtlasDeployment, isGov bool, regionU
7575
return nil
7676
}
7777

78-
func regularDeployment(spec *akov2.AdvancedDeploymentSpec, isGov bool, regionUsageRestrictions string) error {
79-
if isGov {
80-
if err := deploymentForGov(spec, regionUsageRestrictions); err != nil {
81-
return err
82-
}
83-
}
84-
78+
func regularDeployment(spec *akov2.AdvancedDeploymentSpec) error {
8579
var autoscaling akov2.AdvancedAutoScalingSpec
8680
var instanceSize string
8781
for _, replicaSetSpec := range spec.ReplicationSpecs {
@@ -254,19 +248,6 @@ func advancedInstanceSizeInRange(currentInstanceSize, minInstanceSize, maxInstan
254248
return nil
255249
}
256250

257-
func deploymentForGov(spec *akov2.AdvancedDeploymentSpec, regionUsageRestrictions string) error {
258-
for _, replication := range spec.ReplicationSpecs {
259-
for _, region := range replication.RegionConfigs {
260-
regionErr := validCloudGovRegion(regionUsageRestrictions, region.RegionName)
261-
if regionErr != nil {
262-
return fmt.Errorf("deployment in atlas for government support a restricted set of regions: %w", regionErr)
263-
}
264-
}
265-
}
266-
267-
return nil
268-
}
269-
270251
func serverlessDeployment(spec *akov2.ServerlessSpec) error {
271252
supportedProviders := provider.SupportedProviders()
272253
switch {

0 commit comments

Comments
 (0)