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 weight 0 on backends leads to weight 100. #109

Closed
drastawi opened this issue Dec 19, 2018 · 4 comments
Closed

Setting weight 0 on backends leads to weight 100. #109

drastawi opened this issue Dec 19, 2018 · 4 comments

Comments

@drastawi
Copy link

drastawi commented Dec 19, 2018

Setting weight 0 on backends leads to weight 100 in the console and VCL file. It goes without saying that it might be dangerous if the weight 0 backend is not ready for high capacity traffic.

Terraform Version

terraform v0.11.10
+ provider.fastly v0.4.0

Affected Resource(s)

  • backend

Terraform Configuration Files

backends = [
    {
      name = "MyBackend"
      address = "my.backend.com"
      port = 443
      ssl_cert_hostname = "*.my.backend.com"
      ssl_check_cert = true
      use_ssl = true
      min_tls_version = "1.2"
      weight = 0
    }
  ]

Expected Behavior

Should create a backend with a weight 0, or at least throw an input validation error.

Actual Behavior

Creates a backend with a weight 100

Steps to Reproduce

terraform apply

Important Factoids

The terraform apply actually shows the weight is going to be set to 0. You only found out it had been changed to 100 in the console and the VCL file.

Setting the weight to 0 is not a problem in the Fastly console.

@philippschulte
Copy link
Member

👋 thanks for opening this issue!

Should create a backend with a weight 0, or at least throw an input validation error.

I don't think it should create a backend with a weight of 0 because a value of 0 doesn't prevent it from receiving traffic! Useful values for the weight field are integers from 1 to 100. For reference please have a look at the Fastly API Docs. You have to use a condition in order to prevent a backend from receiving traffic. I do agree that the provider should have validation for this field. I'll open a PR to validate the weight field and only let values from 1 to 100 pass it soon.

@drastawi
Copy link
Author

drastawi commented Jul 9, 2019

@philippschulte Please note that setting the value to 0 works in the Fastly console (I recall I verified it decreases the traffic to 0) despite what the docs say. I would argue the behavior should be consistent between the two.

@philippschulte
Copy link
Member

Please note that setting the value to 0 works in the Fastly console (I recall I verified it decreases the traffic to 0) despite what the docs say

I can confirm that the Fastly API accepts a weight of 0 but it also accepts any signed or unsigned integer. The Fastly API doesn't perform any validation for this field.

I would argue the behavior should be consistent between the two.

I agree! However, I need to confirm that

director autodirector_ random {
  {
    .backend = F_Second_backend;
    .weight  = 0;
  }{
    .backend = F_Third_backend;
    .weight  = 100;
  }{
    .backend = F_Fastly;
    .weight  = 100;
  }
}

is actually working as you are reporting. Even if F_Second_backend doesn't get any traffic it doesn't mean that it makes sense! For me it doesn't make any sense at all. A directors purpose is load balancing. If you don't want that F_Second_backend should get any traffic then it should be removed from the director and not the weight set to 0.

I'll discuss this internally with my co-workers. The solution will be a validator the only question is if the range will be from 1-100 or 0-100. In case we decide the range to be 0-100 then it is a larger problem which needs to be solved in the go-fastly HTTP client.

@smaeda-ks
Copy link
Contributor

should be fixed in #511

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.

4 participants