Skip to content

Commit

Permalink
CLOUDP-193173: Add extra args to serverless tags updates
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Vazquez <[email protected]>
  • Loading branch information
josvazg committed Aug 30, 2023
1 parent 00ccf31 commit 1234d83
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 12 deletions.
12 changes: 12 additions & 0 deletions config/crd/bases/atlas.mongodb.com_atlasdeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,14 @@ spec:
serverlessSpec:
description: Configuration for the serverless deployment API. https://www.mongodb.com/docs/atlas/reference/api/serverless-instances/
properties:
backupOptions:
description: Serverless Backup Options
properties:
serverlessContinuousBackupEnabled:
default: true
description: ServerlessContinuousBackupEnabled
type: boolean
type: object
name:
description: Name of the serverless deployment as it appears in
Atlas. After Atlas creates the deployment, you can't change
Expand Down Expand Up @@ -813,6 +821,10 @@ spec:
type: object
maxItems: 50
type: array
terminationProtectionEnabled:
default: false
description: TerminationProtectionEnabled flag
type: boolean
required:
- name
- providerSettings
Expand Down
13 changes: 13 additions & 0 deletions pkg/api/v1/atlasdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ type ServerlessSpec struct {
// +kubebuilder:validation:MaxItems=50
// +optional
Tags []*TagSpec `json:"tags,omitempty"`

// Serverless Backup Options
BackupOptions ServerlessBackupOptions `json:"backupOptions,omitempty"`

// TerminationProtectionEnabled flag
// +kubebuilder:default:=false
TerminationProtectionEnabled bool `json:"terminationProtectionEnabled,omitempty"`
}

// ToAtlas converts the ServerlessSpec to native Atlas client Cluster format.
Expand Down Expand Up @@ -247,6 +254,12 @@ type TagSpec struct {
Value string `json:"value"`
}

type ServerlessBackupOptions struct {
// ServerlessContinuousBackupEnabled
// +kubebuilder:default:=true
ServerlessContinuousBackupEnabled bool `json:"serverlessContinuousBackupEnabled,omitempty"`
}

// ConnectionStrings configuration for applications use to connect to this deployment.
type ConnectionStrings struct {
Standard string `json:"standard,omitempty"`
Expand Down
36 changes: 26 additions & 10 deletions pkg/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ func advancedDeploymentMatchesSpec(log *zap.SugaredLogger, atlasSpec *mongodbatl
return d == "", nil
}

// Parse through tags and verfiy that all keys are unique. Return error otherwise.
// Parse through tags and verify that all keys are unique. Return error otherwise.
func uniqueKey(deploymentSpec *mdbv1.AtlasDeploymentSpec) error {
store := make(map[string]string)
var arrTags []*mdbv1.TagSpec
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/atlasdeployment/serverless_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ func ensureServerlessInstanceState(ctx *workflow.Context, project *mdbv1.AtlasPr
}
if !isTagsEqual(*(atlasDeployment.Tags), *(convertedDeployment.Tags)) {
atlasDeployment, _, err = ctx.Client.ServerlessInstances.Update(context.Background(), project.Status.ID, serverlessSpec.Name, &mongodbatlas.ServerlessUpdateRequestParams{
// TODO: include ServerlessBackupOptions and TerminationProtectionEnabled
Tag: convertedDeployment.Tags,
ServerlessBackupOptions: &mongodbatlas.ServerlessBackupOptions{
ServerlessContinuousBackupEnabled: &serverlessSpec.BackupOptions.ServerlessContinuousBackupEnabled,
},
TerminationProtectionEnabled: &serverlessSpec.TerminationProtectionEnabled,
})
if err != nil {
return atlasDeployment, workflow.Terminate(workflow.DeploymentNotUpdatedInAtlas, err.Error())
Expand Down

0 comments on commit 1234d83

Please sign in to comment.