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

Setting Pause cluster to true raises error #47

Open
dbamohsin opened this issue Sep 21, 2018 · 7 comments
Open

Setting Pause cluster to true raises error #47

dbamohsin opened this issue Sep 21, 2018 · 7 comments
Labels
bug Something isn't working

Comments

@dbamohsin
Copy link

Hi,

When making a change to set a cluster resource to paused, the following error is received and the plan is not applied.

mongodbatlas_cluster.valuations: Modifying... (ID: xxxxx)
  paused: "false" => "true"
Error: Error applying plan:

1 error(s) occurred:

* mongodbatlas_cluster.valuations: 1 error(s) occurred:

* mongodbatlas_cluster.valuations: Error reading MongoDB Cluster valuations: MongoDB Atlas: 409 Cannot update and pause cluster valuations at the same time.
@akshaykarle
Copy link
Owner

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?

@dbamohsin
Copy link
Author

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

@akshaykarle
Copy link
Owner

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.

@dbamohsin
Copy link
Author

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.

Replicating this in the API:

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"

@dbamohsin
Copy link
Author

HI Akshay,

has this been verified? it still causes us problems when pausing clusters.

Thanks

Mohsin

@akshaykarle
Copy link
Owner

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?

@akshaykarle akshaykarle added the bug Something isn't working label Nov 25, 2018
@dbamohsin
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants