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

Changing a weight can remove a backend from a director #143

Closed
drastawi opened this issue Apr 10, 2019 · 2 comments · Fixed by #304
Closed

Changing a weight can remove a backend from a director #143

drastawi opened this issue Apr 10, 2019 · 2 comments · Fixed by #304

Comments

@drastawi
Copy link

drastawi commented Apr 10, 2019

Terraform Version

0.11.13

Affected Resource(s)

fastly_service_v1

Terraform Configuration Files

I updated the weight from 99 to 9 in the file below:

resource "fastly_service_v1" "fastly_service" {
  name = "${var.fastly_project_name}"

  domain {
    name = "${var.domain_name}"
  }

  backend ="${var.backends}" 

  // To fix the issue https://github.com/terraform-providers/terraform-provider-fastly/issues/109,
  // we only put the backends with weight greater than 0 in the director.
  director {
    name = "director"
    backends = [ "${compact(data.null_data_source.non_zero_weight_backends.*.outputs.name)}"]
    quorum = 1
  }
}
data "null_data_source" "non_zero_weight_backends" {
  count = "${length(var.backends)}"
  inputs = {
    name = "${lookup(var.backends[count.index], "weight") == 0 ? "" : lookup(var.backends[count.index], "name")}"
  }
}
backends = [
    {
      name = "xxxxx Public API (xxxxx)"
      address = xxxxx
      port = 443
      ssl_cert_hostname = xxxxx
      ssl_check_cert = true
      use_ssl = true
      min_tls_version = "1.2"

      weight = 9
    },
    {
      name = "xxxx Public API"
      address = xxxxx
      port = 443
      ssl_cert_hostname = xxxxx
      ssl_check_cert = true
      use_ssl = true
      min_tls_version = "1.2"

      weight = 1
    }
  ]

Debug Output

  backend.205921849.address:                "xxxx"
  backend.205921849.auto_loadbalance:       "true" => "true"
  backend.205921849.between_bytes_timeout:  "10000" => "10000"
  backend.205921849.connect_timeout:        "1000" => "1000"
  backend.205921849.error_threshold:        "0" => "0"
  backend.205921849.first_byte_timeout:     "15000" => "15000"
  backend.205921849.healthcheck:            "" => ""
  backend.205921849.max_conn:               "200" => "200"
  backend.205921849.max_tls_version:        "" => ""
  backend.205921849.min_tls_version:        "1.2" => "1.2"
  backend.205921849.name:                   "xxx"
  backend.205921849.port:                   "443" => "443"
  backend.205921849.request_condition:      "" => ""
  backend.205921849.shield:                 "" => ""
  backend.205921849.ssl_ca_cert:            "" => ""
  backend.205921849.ssl_cert_hostname:      "xxx"
  backend.205921849.ssl_check_cert:         "true" => "true"
  backend.205921849.ssl_ciphers:            "" => ""
  backend.205921849.ssl_client_cert:        "<sensitive>" => "<sensitive>"
  backend.205921849.ssl_client_key:         "<sensitive>" => "<sensitive>"
  backend.205921849.ssl_hostname:           "" => ""
  backend.205921849.ssl_sni_hostname:       "" => ""
  backend.205921849.use_ssl:                "true" => "true"
  backend.205921849.weight:                 "1" => "1"
  backend.2547690010.address:               "" => "xxxx"
  backend.2547690010.auto_loadbalance:      "" => "true"
  backend.2547690010.between_bytes_timeout: "" => "10000"
  backend.2547690010.connect_timeout:       "" => "1000"
  backend.2547690010.error_threshold:       "" => "0"
  backend.2547690010.first_byte_timeout:    "" => "15000"
  backend.2547690010.healthcheck:           "" => ""
  backend.2547690010.max_conn:              "" => "200"
  backend.2547690010.max_tls_version:       "" => ""
  backend.2547690010.min_tls_version:       "" => "1.2"
  backend.2547690010.name:                  "" => "xxxx"
  backend.2547690010.port:                  "" => "443"
  backend.2547690010.request_condition:     "" => ""
  backend.2547690010.shield:                "" => ""
  backend.2547690010.ssl_ca_cert:           "" => ""
  backend.2547690010.ssl_cert_hostname:     "" => "xxxx"
  backend.2547690010.ssl_check_cert:        "" => "true"
  backend.2547690010.ssl_ciphers:           "" => ""
  backend.2547690010.ssl_client_cert:       "<sensitive>" => "<sensitive>"
  backend.2547690010.ssl_client_key:        "<sensitive>" => "<sensitive>"
  backend.2547690010.ssl_hostname:          "" => ""
  backend.2547690010.ssl_sni_hostname:      "" => ""
  backend.2547690010.use_ssl:               "" => "true"
  backend.2547690010.weight:                "" => "9"
  backend.2898937851.address:               "xxx" => ""
  backend.2898937851.auto_loadbalance:      "true" => "false"
  backend.2898937851.between_bytes_timeout: "10000" => "0"
  backend.2898937851.connect_timeout:       "1000" => "0"
  backend.2898937851.error_threshold:       "0" => "0"
  backend.2898937851.first_byte_timeout:    "15000" => "0"
  backend.2898937851.healthcheck:           "" => ""
  backend.2898937851.max_conn:              "200" => "0"
  backend.2898937851.max_tls_version:       "" => ""
  backend.2898937851.min_tls_version:       "1.2" => ""
  backend.2898937851.name:                  "xxx" => ""
  backend.2898937851.port:                  "443" => "0"
  backend.2898937851.request_condition:     "" => ""
  backend.2898937851.shield:                "" => ""
  backend.2898937851.ssl_ca_cert:           "" => ""
  backend.2898937851.ssl_cert_hostname:     "xxxx" => ""
  backend.2898937851.ssl_check_cert:        "true" => "false"
  backend.2898937851.ssl_ciphers:           "" => ""
  backend.2898937851.ssl_client_cert:       "" => ""
  backend.2898937851.ssl_client_key:        "" => ""
  backend.2898937851.ssl_hostname:          "" => ""
  backend.2898937851.ssl_sni_hostname:      "" => ""
  backend.2898937851.use_ssl:               "true" => "false"
  backend.2898937851.weight:                "99" => "0"

Expected Behavior

The director should update the weight in the VCL

Actual Behavior

The API removed the backend with the updated weight from the director.

Steps to Reproduce

  1. Updated the weight on one backend
  2. terraform apply

Important Factoids

Running apply again fixes the issue with the plan:

  director.1777961031.backends.#:          "0" => "2"
  director.1777961031.backends.3220782306: "" => "xxxx"
  director.1777961031.backends.3231695452: "" => "xxxx"
  director.1777961031.capacity:            "" => "100"
  director.1777961031.comment:             "" => ""
  director.1777961031.name:                "" => "director"
  director.1777961031.quorum:              "" => "1"
  director.1777961031.retries:             "" => "5"
  director.1777961031.shield:              "" => ""
  director.1777961031.type:                "" => "1"
  director.2719870166.backends.#:          "1" => "0"
  director.2719870166.backends.3220782306: "xxxxI" => ""
  director.2719870166.capacity:            "100" => "0"
  director.2719870166.comment:             "" => ""
  director.2719870166.name:                "director" => ""
  director.2719870166.quorum:              "1" => "0"
  director.2719870166.retries:             "5" => "0"
  director.2719870166.shield:              "" => ""
  director.2719870166.type:                "1" => "0"
@libc
Copy link

libc commented Jun 19, 2019

This seems to happen on any backend update, not just weights. The underlying problem is that there're no in-place updates of backends, all changes are done by deleting and adding them. After deletion the link between director and backend is lost.

@phamann
Copy link
Member

phamann commented Sep 2, 2020

Hi all, just a quick update to say this has now been fixed (#304) and released in version v0.20.1 of the provider. Feel free to reopen if you have further issues.

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

Successfully merging a pull request may close this issue.

3 participants