Closed johnsudaar closed 6 months ago
@johnsudaar : If I understand well, I guess the issue's title should read "should not be optional", doesn't it?
I also have a comment/question. When an autoscaler is configured and enabled on an app:
For our Terraform provider, I think we should stick with the API behavior, so using:
resource "scalingo_container_type" "web" {
app = "[APP_ID]"
name = "web"
size = "2XL"
amount = 1
}
would actually disable the autoscaler and scale the app to web:1:2XL
.
In your example it would be a bit weird to define an autoscaler and then disable it right afterwards, wouldn't it? Is that OK?
Sorry I missed your comment here.
No the issue title is right. But i might've not explained the issue correctly.
Currently the field is indeed marked as Optional and indeed i think it should be. Because the autoscaler only let users do horizontal scaling where the scalingo_container_type
resource permit users to do both horizontal and vertical scaling.
So if we apply the changes you propose, we wont be able to change the vertical scalingo of containers managed by an autoscaler by using terraform.
IMHO, we should ensure that if the amount
parameter is not passed to the resource, it should also not be sent to the API. This is not the current behavior: if we do not pass the amount
variable we will scale it to 0 containers.
Currently we mark the
amount
parameter of the container type as optional. However if it's not specified the request will send a value of0
instead of not using it at all.This is due to this line: https://github.com/Scalingo/terraform-provider-scalingo/blob/master/scalingo/resource_scalingo_container_type.go#L62 (and this one: https://github.com/Scalingo/terraform-provider-scalingo/blob/master/scalingo/resource_scalingo_container_type.go#L113).
This behavior is dangerous. Because if a client wants to just scale vertically the containers will be scaled to 0. This is especially dangerous with autoscaler where we might be tempted to write:
We might expect that this creates an autoscaler on the "web" container type that uses 5 to 10 2XL when in fact this will scale the
web
containers to 0.