Skip to content
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

CLOUDP-193173: Add extra args to serverless tags updates #1115

Merged
merged 1 commit into from
Aug 31, 2023
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
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
Loading