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

Autoscale does not play well if you set topologies #467

Closed
4 tasks done
kuisathaverat opened this issue Apr 12, 2022 · 2 comments
Closed
4 tasks done

Autoscale does not play well if you set topologies #467

kuisathaverat opened this issue Apr 12, 2022 · 2 comments
Assignees
Labels
bug Something isn't working framework-limitation This issue is caused by limitations of the Terraform SDK Known issue Known issue that is well documented Team:Stack-And-Solutions.important
Milestone

Comments

@kuisathaverat
Copy link
Contributor

kuisathaverat commented Apr 12, 2022

Readiness Checklist

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I am reporting the issue to the correct repository (for multi-repository projects)

Expected Behavior

A terraform manifest should work after autoscaling resizes the cluster.

Current Behavior

The terraform apply will fail with different errors, but all are related to the fact that autoscale has changed the size and the plan generated by the elastic terraform provider does not have those changes and the resulting plan is incompatible with the currently deployed. Some of the issues are:

## Terraform definition

Case 1

terraform {
  required_version = ">= 0.12.29"

  required_providers {
    ec = {
      source  = "elastic/ec"
      version = "0.4.0"
    }
  }
}

provider "ec" {
  endpoint = "https://cloud.elastic.co"
  insecure = true
  apikey = "<<REDACTED>>"

  verbose = false
}

# Create an Elastic Cloud deployment
resource "ec_deployment" "main" {
  name = "test-half-stack-oblt"

  # Mandatory fields
  region                 = "gcp-us-west2"
  version                = "8.2.0"
  deployment_template_id = "gcp-io-optimized-v2"

  elasticsearch {
    autoscale = true
    topology {
      id   = "hot_content"
      size = "2g" 
    }
    config {
      user_settings_yaml = file("./es_settings.yml")
    }
  }

  kibana {}

  integrations_server {}
}

Case 2

terraform {
  required_version = ">= 0.12.29"

  required_providers {
    ec = {
      source  = "elastic/ec"
      version = "0.4.0"
    }
  }
}

provider "ec" {
  endpoint = "https://cloud.elastic.co"
  insecure = true
  apikey = "<<REDACTED>>"

  verbose = false
}

# Create an Elastic Cloud deployment
resource "ec_deployment" "main" {
  name = "test-half-stack-oblt"

  # Mandatory fields
  region                 = "gcp-us-west2"
  version                = "8.2.0"
  deployment_template_id = "gcp-io-optimized-v2"

  elasticsearch {
    autoscale = true
    topology {
      id   = "hot_cold"
    }
    topology {
      id   = "hot_content"
    }
    topology {
      id   = "hot_warm"
    }
    config {
      user_settings_yaml = file("./es_settings.yml")
    }
  }

  kibana {}

  integrations_server {}
}

Case 3

terraform {
  required_version = ">= 0.12.29"

  required_providers {
    ec = {
      source  = "elastic/ec"
      version = "0.4.0"
    }
  }
}

provider "ec" {
  endpoint = "https://cloud.elastic.co"
  insecure = true
  apikey = "<<REDACTED>>"

  verbose = false
}

# Create an Elastic Cloud deployment
resource "ec_deployment" "main" {
  name = "test-half-stack-oblt"

  # Mandatory fields
  region                 = "gcp-us-west2"
  version                = "8.2.0"
  deployment_template_id = "gcp-io-optimized-v2"

  elasticsearch {
    autoscale = true
    topology {
      id   = "hot_content"
    }
    topology {
      id   = "ml"
    }
    config {
      user_settings_yaml = file("./es_settings.yml")
    }
  }

  kibana {}

  integrations_server {}
}

Steps to Reproduce

  1. Apply any of the configurations above
  2. ingest data into the cluster to make the autoscale size the cluster to 6 nodes
  3. try to apply the terraform manifest again

Context

We change settings on elasticsearch using the settings file we pass in the terraform manifest, we also add node types sometimes, or we changed configuration on Kibana, Integrations server, or simply we changed the cluster used to monitor the cluster. Those changes do not work well with autoscaling and some terraform configurations.

Possible Solution

The workaround we use is to set the cluster without autoscale and the resources we will need, after that, we remove all the topology setting from elasticsearch and we use autoscale.

Initial deploy

terraform {
  required_version = ">= 0.12.29"

  required_providers {
    ec = {
      source  = "elastic/ec"
      version = "0.4.0"
    }
  }
}

provider "ec" {
  endpoint = "https://cloud.elastic.co"
  insecure = true
  apikey = "<<REDACTED>>"

  verbose = false
}

# Create an Elastic Cloud deployment
resource "ec_deployment" "main" {
  name = "test-half-stack-oblt"

  # Mandatory fields
  region                 = "gcp-us-west2"
  version                = "8.2.0"
  deployment_template_id = "gcp-io-optimized-v2"

  elasticsearch {
    autoscale = false
    topology {
      id   = "hot_content"
      size = "16g"
      zone_count = 2
    }
    topology {
      id   = "ml"
      size = "2g"
    }
    config {
      user_settings_yaml = file("./es_settings.yml")
    }
  }

  kibana {}

  integrations_server {}
}

Autoscale update

terraform {
  required_version = ">= 0.12.29"

  required_providers {
    ec = {
      source  = "elastic/ec"
      version = "0.4.0"
    }
  }
}

provider "ec" {
  endpoint = "https://cloud.elastic.co"
  insecure = true
  apikey = "<<REDACTED>>"

  verbose = false
}

# Create an Elastic Cloud deployment
resource "ec_deployment" "main" {
  name = "test-half-stack-oblt"

  # Mandatory fields
  region                 = "gcp-us-west2"
  version                = "8.2.0"
  deployment_template_id = "gcp-io-optimized-v2"

  elasticsearch {
    autoscale = true
    config {
      user_settings_yaml = file("./es_settings.yml")
    }
  }

  kibana {}

  integrations_server {}
}


## Your Environment
<!--- Include as many relevant details about the environment -->
<!--- you experienced the bug in. -->
* Version used: 0.4.0
* Running against Elastic Cloud SaaS or Elastic Cloud Enterprise and version: ESS
* Environment name and version (e.g. Go 1.9):
* Server type and version:
* Operating System and version: macOS 12.3.1
* Link to your project:
@kuisathaverat kuisathaverat added the bug Something isn't working label Apr 12, 2022
@Kushmaro Kushmaro modified the milestones: 0.6.0, 0.5.0 Aug 9, 2022
@dimuon dimuon added framework-limitation This issue is caused by limitations of the Terraform SDK Known issue Known issue that is well documented labels Sep 5, 2022
@dimuon
Copy link
Contributor

dimuon commented Sep 5, 2022

I think the considerations from #466 (comment) can be applied here as well.

@Kushmaro Kushmaro modified the milestones: 0.5.0, 0.6.0 Oct 18, 2022
@dimuon
Copy link
Contributor

dimuon commented Mar 1, 2023

Closed by #567

@dimuon dimuon closed this as completed Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working framework-limitation This issue is caused by limitations of the Terraform SDK Known issue Known issue that is well documented Team:Stack-And-Solutions.important
Projects
None yet
Development

No branches or pull requests

4 participants