Open dbamohsin opened 6 years ago
Looks like the MongoDB Atlas API returned a 409 because the cluster is paused. You might have to file a ticket with Mongo Support about this maybe?
Hi Akshay,
Just to clarify, the cluster was in a running state and this was an attempt to set pause to true. Ive found that the same issue happens if you try to set a paused cluster to running.
This issue only happens if using the provider. Doing the same actions via the API works fine.
Thanks
Thanks for that clarification @dbamohsin. Could you please share the API endpoints and payload you used to update your cluster? Also, attaching the terraform file and the state file would help me reproduce the error locally.
Hi Akshay.
Here is some detail around the issue.
mongodb-atlas.tf - creating the cluster works fine (with paused set to false)
mongo_create_cluster_map = {
"core" = true
}
mongo_cluster_spec_core = {
"node_size" = "M10"
"disk_size" = 10
"backup_enabled" = false
"disk_autogrow" = false
"paused" = false #Issue raised with terraform provider as setting to true raises a 409 error code.
}
resource "mongodbatlas_cluster" "core" {
count = "${lookup(var.mongo_create_cluster_map, "core")}"
name = "core"
group = "${module.mongodb-atlas.projectid}"
mongodb_major_version = "3.6"
provider_name = "GCP"
region = "" # leave blank if using a replication spec
replication_spec {
region = "EUROPE_WEST_4"
priority = 7
electable_nodes = 2
}
replication_spec {
region = "EUROPE_WEST_3"
priority = 6
electable_nodes = 1
}
replication_factor = 0
# Options which can differ per environment.
size = "${lookup(var.mongo_cluster_spec_core, "node_size")}"
backup = "${lookup(var.mongo_cluster_spec_core, "backup_enabled")}"
disk_gb_enabled = "${lookup(var.mongo_cluster_spec_core, "disk_autogrow")}"
disk_size_gb = "${lookup(var.mongo_cluster_spec_core, "disk_size")}"
paused = "${lookup(var.mongo_cluster_spec_core, "paused")}"
depends_on = ["module.mongodb-atlas"]
timeouts {
create = "20m"
delete = "40m"
update = "24h"
}
}
when attempting to set the cluster state to paused by changing the paused to true:
mongo_cluster_spec_core = {
"node_size" = "M10"
"disk_size" = 10
"backup_enabled" = false
"disk_autogrow" = false
"paused" = true #Issue raised with terraform provider as setting to true raises a 409 error code.
}
Produces the following plan:
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ mongodbatlas_cluster.core
paused: "false" => "true"
Plan: 0 to add, 1 to change, 0 to destroy.
and produces the following error on apply:
mongodbatlas_cluster.core: Modifying... (ID: xxxxxx)
paused: "false" => "true"
Error: Error applying plan:
1 error(s) occurred:
* mongodbatlas_cluster.core: 1 error(s) occurred:
* mongodbatlas_cluster.core: Error reading MongoDB Cluster core: MongoDB Atlas: 409 Cannot update and pause cluster core at the same time.
The following API call works successfully to set the cluster state to paused:
curl -X PATCH -i --digest -u "myuser:xxxxxx" -H "Content-Type: application/json" \
"https://cloud.mongodb.com/api/atlas/v1.0/groups/{PROJECT-ID}/clusters/core?pretty=true" \
--data '
{
"paused" : false
}'
Payload (sanitised):
HTTP/1.1 200 OK
Date: Wed, 26 Sep 2018 21:01:44 GMT
Content-Type: application/json
Strict-Transport-Security: max-age=300
Content-Length: 2142
{
"autoScaling" : {
"diskGBEnabled" : false
},
"backupEnabled" : false,
"biConnector" : {
"enabled" : false,
"readPreference" : "secondary"
},
"clusterType" : "REPLICASET",
"diskSizeGB" : 10.0,
"encryptionAtRestProvider" : "NONE",
"groupId" : "xxxxx",
"id" : "xxxxx",
"links" : [ {
"href" : "https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxx/clusters/core,
"rel" : "self"
}, {
"href" : "https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxx/clusters/core/restoreJobs",
"rel" : "http://mms.mongodb.com/restoreJobs"
}, {
"href" : "https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxx/clusters/core/snapshots",
"rel" : "http://mms.mongodb.com/snapshots"
} ],
"mongoDBMajorVersion" : "3.6",
"mongoDBVersion" : "3.6.7",
"mongoURI" : "mongodb://myuri",
"mongoURIUpdated" : "2018-09-26T14:47:52Z",
"mongoURIWithOptions" : "mongodb://myuriwithoptions/?ssl=true&authSource=admin&replicaSet=core-shard-0",
"name" : "core",
"numShards" : 1,
"paused" : true,
"providerBackupEnabled" : false,
"providerSettings" : {
"providerName" : "GCP",
"instanceSizeName" : "M10"
},
"replicationSpec" : {
"EUROPE_WEST_3" : {
"electableNodes" : 1,
"priority" : 6,
"readOnlyNodes" : 0
},
"EUROPE_WEST_4" : {
"electableNodes" : 2,
"priority" : 7,
"readOnlyNodes" : 0
}
},
"replicationSpecs" : [ {
"id" : "xxxxx",
"numShards" : 1,
"regionsConfig" : {
"EUROPE_WEST_3" : {
"electableNodes" : 1,
"priority" : 6,
"readOnlyNodes" : 0
},
"EUROPE_WEST_4" : {
"electableNodes" : 2,
"priority" : 7,
"readOnlyNodes" : 0
}
},
"zoneName" : "Zone 1"
} ],
"stateName" : "UPDATING"
HI Akshay,
has this been verified? it still causes us problems when pausing clusters.
Thanks
Mohsin
Hey @dbamohsin I still haven't had time to verify this. But in the api payload you've sent, you set the paused
value to false. Is that the correct payload you sent?
Hi Akshay,
Good spot, the API payload should have been
curl -X PATCH -i --digest -u "myuser:xxxxxx" -H "Content-Type: application/json" \
"https://cloud.mongodb.com/api/atlas/v1.0/groups/{PROJECT-ID}/clusters/core?pretty=true" \
--data '
{
"paused" : true
}'
Payload output:
HTTP/1.1 200 OK
Date: Wed, 26 Sep 2018 21:01:44 GMT
Content-Type: application/json
Strict-Transport-Security: max-age=300
Content-Length: 2142
{
"autoScaling" : {
"diskGBEnabled" : false
},
"backupEnabled" : false,
"biConnector" : {
"enabled" : false,
"readPreference" : "secondary"
},
"clusterType" : "REPLICASET",
"diskSizeGB" : 10.0,
"encryptionAtRestProvider" : "NONE",
"groupId" : "xxxxx",
"id" : "xxxxx",
"links" : [ {
"href" : "https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxx/clusters/core,
"rel" : "self"
}, {
"href" : "https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxx/clusters/core/restoreJobs",
"rel" : "http://mms.mongodb.com/restoreJobs"
}, {
"href" : "https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxx/clusters/core/snapshots",
"rel" : "http://mms.mongodb.com/snapshots"
} ],
"mongoDBMajorVersion" : "3.6",
"mongoDBVersion" : "3.6.7",
"mongoURI" : "mongodb://myuri",
"mongoURIUpdated" : "2018-09-26T14:47:52Z",
"mongoURIWithOptions" : "mongodb://myuriwithoptions/?ssl=true&authSource=admin&replicaSet=core-shard-0",
"name" : "core",
"numShards" : 1,
"paused" : true,
"providerBackupEnabled" : false,
"providerSettings" : {
"providerName" : "GCP",
"instanceSizeName" : "M10"
},
"replicationSpec" : {
"EUROPE_WEST_3" : {
"electableNodes" : 1,
"priority" : 6,
"readOnlyNodes" : 0
},
"EUROPE_WEST_4" : {
"electableNodes" : 2,
"priority" : 7,
"readOnlyNodes" : 0
}
},
"replicationSpecs" : [ {
"id" : "xxxxx",
"numShards" : 1,
"regionsConfig" : {
"EUROPE_WEST_3" : {
"electableNodes" : 1,
"priority" : 6,
"readOnlyNodes" : 0
},
"EUROPE_WEST_4" : {
"electableNodes" : 2,
"priority" : 7,
"readOnlyNodes" : 0
}
},
"zoneName" : "Zone 1"
} ],
"stateName" : "UPDATING"
I have tested both ways via the API and it works as it should.
Hi,
When making a change to set a cluster resource to paused, the following error is received and the plan is not applied.