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

Unable to disable node draining in rancher2_cluster #440

Closed
ryanelliottsmith opened this issue Aug 31, 2020 · 1 comment · Fixed by #498
Closed

Unable to disable node draining in rancher2_cluster #440

ryanelliottsmith opened this issue Aug 31, 2020 · 1 comment · Fixed by #498
Assignees

Comments

@ryanelliottsmith
Copy link

ryanelliottsmith commented Aug 31, 2020

Steps to reproduce

  1. Apply TF code to create node_pool, node_template and cluster with drain enabled:
provider "rancher2" {
  api_url    = "https://xxxxx"
  token_key = "xxxxx"
}

resource "rancher2_cluster" "custom" {
  name = "custom-rke"
  description = "custom cluster"
  rke_config {
    network {
      plugin = "canal"
    }
    upgrade_strategy {
      drain = true
    }    
  }
}
resource "rancher2_node_template" "aws" {
  name = "aws-nt"
  description = "test"
  amazonec2_config {
    access_key = "XXXX"
    secret_key = "XXXX"
    ami =  "XXXX"
    instance_type = "XXXX"
    region = "XXXX"
    security_group = ["XXXX"]
    subnet_id = "XXXX"
    vpc_id = "XXXX"
    zone = "a"
  }
}
resource "rancher2_node_pool" "aws-np" {
  cluster_id =  rancher2_cluster.custom.id
  name = "aws-np"
  hostname_prefix =  "tf-"
  node_template_id = rancher2_node_template.aws.id
  quantity = 3
  control_plane = true
  etcd = true
  worker = true
}
  1. Wait for Rancher to create and reconcile cluster
  2. Confirm that drain nodes is "true" from within Rancher
  3. Modify TF code to set drain=false within the upgrade_strategy and apply with terraform apply
      rke_config {
        upgrade_strategy {
          drain = false
        }
  1. Note that drain nodes is still "true"

Versions
Rancher - v2.4.5
Terraform - v0.12.20
rancher2 provider - v1.10.1

gz#12021

@rawmind0
Copy link
Contributor

@ryanelliottsmith , as upgrade_strategy.drain go struct is defined as bool with json:"drain,omitempty" yaml:"drain,omitempty" on Rancher API, drain = false is treated as empty value and it's omitted on API request when json is marshalled. This issue should be open on Rancher to update bool field to *bool or to avoid omitempty on bool definition on the Rancher API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants