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

Cluster resource's provider_instance_size_name should be optional when using autoscaling #1299

Open
AaronFriel opened this issue Jul 7, 2023 · 6 comments
Labels
not_stale Not stale issue or PR

Comments

@AaronFriel
Copy link

When autoscaling is enabled, applying configurations which set the provider_instance_size_name field reset the autoscaled instance size to the configured value.

Users would almost certainly prefer that when auto_scaling_compute_enabled is true, they do not need to set this value or the value is ignored (and the configuration in state is returned on Read) so that plans do not update the cluster resource.

First reported by a Pulumi user here:

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

Thanks for opening this issue. The ticket INTMDB-916 was created for internal tracking.

@colm-quinn
Copy link
Collaborator

colm-quinn commented Jul 7, 2023

Hi @AaronFriel,
For auto-scaling, we currently advise customers to ignore the instance_size setting in their Terraform state, see docs at: https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/advanced_cluster#compute_enabled

For an example, see #1288 (comment). Can you confirm if the ignore works for you here?

If so, we can look to improving the docs & examples here to make the ignore_changes steps clearer/more explicit.

@colm-quinn colm-quinn added the not_stale Not stale issue or PR label Jul 7, 2023
@AaronFriel
Copy link
Author

AaronFriel commented Jul 8, 2023

@colm-quinn understood, I'm being a bit prescriptive here with regard to "ignore-changes". We at Pulumi see this fairly often with users filing bug reports against providers. This report I filed was the second or third in one day in which the workaround is to use ignore_changes. Users often miss this instruction, the provider doesn't behave as expected, and it can be very frustrating.

Rather than rely on ignore_changes, a couple tweaks to the provider implementation result in more users falling on the golden path. Either of these work, though the first is preferable as it keeps the output value usable as an input to other resources.

  1. Make the field optional, and raise an error when it's required on Create/Update or log a warning when it's set unnecessarily. This puts the user on the right path pretty quickly.
  2. Modify the resource methods to ignore this value - essentially always return what's in state.

@gregoirefra
Copy link

Hi folks, I wanted to add another perspective on this.

Relying on ignore_changes makes it hard in scenarios where the cluster definition is inside a module. For example, we declare the cluster and other relevant Atlas resources as part of a module that is re-used across more than one environment but not all MongoDB Atlas clusters are expected to be configured with auto-scaling. Because of this, having an ignore_change inside the module with the cluster definition would prevent us from re-using it since all declarations of the module would ignore the instance size and be forced to set auto-scaling to true with corresponding min and max values.

Here is an example definition of what I'm mentioning.

Module definition:

resource "mongodbatlas_advanced_cluster" "cluster" {
  project_id   = var.project_id
  name         = var.name
  cluster_type = "REPLICASET"
  replication_specs {
    region_configs {
      electable_specs {
        node_count = 3
        instance_size = var.auto_scaling ? null : var.instance_size
      }
      auto_scaling {
        disk_gb_enabled           = true
        compute_enabled           = var.auto_scaling
        compute_min_instance_size = var.auto_scaling ? var.auto_scaling_min : null
        compute_max_instance_size = var.auto_scaling ? var.auto_scaling_max : null
      }
      provider_name = "AWS"
      priority      = 7
      region_name   = "US_EAST_1"
    }
  }
}
}

First environment:

module "atlas"{
  source = "./atlas"
  project_id = "my_project_id"
  name = "no_autoscaling"
  auto_scaling = false
  instance_size = "M10"
}

Second environment:

module "atlas"{
  source = "./atlas"
  project_id = "my_project_id"
  name = "no_autoscaling"
  auto_scaling = true
  auto_scaling_min = "M10"
  auto_scaling_max = "M80"
}

So by using ignore_changes here, it would become impossible for us to modify the size of the cluster in the first environment.

Also based on the documentation this should be supported as the instance_size is marked as optional but it doesn't seem to be the case. I've opened a separate issue for this.

@Zuhairahmed
Copy link
Collaborator

Hi just as an update this item is on our roadmap, but still several quarters away. internal tracking ticket CLOUDP-215040

@OlehHarmash
Copy link

Hi just as an update this item is on our roadmap, but still several quarters away. internal tracking ticket CLOUDP-215040

Hello

Our team is also interested in that feature.
Do you have any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not_stale Not stale issue or PR
Projects
None yet
Development

No branches or pull requests

5 participants