Skip to content

Commit 3903fde

Browse files
allow update in paused and other changes within same update
1 parent 43a556b commit 3903fde

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

cfn-resources/cluster/cmd/resource/resource.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
126126
return *pe, nil
127127
}
128128

129-
// handle unpausing update
130-
if pe, _ := handleUnpausingUpdate(client, currentCluster, currentModel); pe != nil {
129+
// Unpausing must be handled separately from other updates to avoid errors from the API.
130+
if pe := handleUnpausingUpdate(client, currentCluster, currentModel); pe != nil {
131131
return *pe, nil
132132
}
133133

@@ -160,24 +160,16 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
160160
return event, nil
161161
}
162162

163-
func handleUnpausingUpdate(client *util.MongoDBClient, currentCluster *admin20231115014.AdvancedClusterDescription, currentModel *Model) (*handler.ProgressEvent, error) {
163+
func handleUnpausingUpdate(client *util.MongoDBClient, currentCluster *admin20231115014.AdvancedClusterDescription, currentModel *Model) *handler.ProgressEvent {
164164
if (currentCluster.Paused != nil && *currentCluster.Paused) && (currentModel.Paused == nil || !*currentModel.Paused) {
165-
cluster, resp, err := client.Atlas20231115014.ClustersApi.UpdateCluster(context.Background(), *currentModel.ProjectId, *currentModel.Name,
165+
_, resp, err := client.Atlas20231115014.ClustersApi.UpdateCluster(context.Background(), *currentModel.ProjectId, *currentModel.Name,
166166
&admin20231115014.AdvancedClusterDescription{Paused: admin20231115014.PtrBool(false)}).Execute()
167167
if pe := util.HandleClusterError(err, resp); pe != nil {
168-
return pe, nil
168+
return pe
169169
}
170-
// returns InProgress event directly, if any other changes are made they will not be performed as part of this update operation
171-
event := handler.ProgressEvent{
172-
OperationStatus: handler.InProgress,
173-
Message: fmt.Sprintf("Unpausing Cluster %s", *cluster.StateName),
174-
ResourceModel: currentModel,
175-
CallbackDelaySeconds: callBackSeconds,
176-
CallbackContext: callbackContext,
177-
}
178-
return &event, nil
170+
return nil
179171
}
180-
return nil, nil
172+
return nil
181173
}
182174

183175
// Delete handles the Delete event from the Cloudformation service.

cfn-resources/cluster/docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ _Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/l
203203

204204
#### Paused
205205

206-
Flag that indicates whether the cluster is paused or not. When unpausing a cluster the update operaton will not perform any other changes to the cluster.
206+
Flag that indicates whether the cluster is paused or not.
207207

208208
_Required_: No
209209

cfn-resources/cluster/mongodb-atlas-cluster.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
"type": "string"
415415
},
416416
"Paused": {
417-
"description": "Flag that indicates whether the cluster is paused or not. When unpausing a cluster the update operaton will not perform any other changes to the cluster.",
417+
"description": "Flag that indicates whether the cluster is paused or not.",
418418
"type": "boolean"
419419
},
420420
"PitEnabled": {

0 commit comments

Comments
 (0)