Closed peter-svensson closed 3 years ago
A possible fix might be to remove the checks for zero values in the DataSource_XXX.generated.go
files:
if reflect.DeepEqual(in, reflect.Zero(reflect.TypeOf(in)).Interface()) {
return nil
}
Removing those will set the value to *false
instead of nil
which seems to work fine at least for my small test
Hello, thanks for reporting the issue. This is a general problem in terraform that does not distinguish zero values and values not set in config.
One way to disable the behaviour is to mark the field mandatory.
I will look at it today or tomorrow.
@peter-svensson there was this fix https://github.com/eddycharly/terraform-provider-kops/issues/256 I applied to anonymous auth, I wonder if something similar would make sense here. WDYT ?
Probably, but there are a lot of places where this will have to be applied?
The metrics_server
was just an example, the issue I discovered was for the cluster autoscaler addon.
Indeed it could be needed in a lot of places.
I'm not sure how kOps handles nil
vs false
(maybe when the field is nil
kOps has some internal logic to determine the value to apply).
I will try to dig a bit deeper in the kOps code.
Any progress on this? Anyway I can help?
The metrics_server was just an example, the issue I discovered was for the cluster autoscaler addon.
What attribute was causing the issue in the autoscaler addon please ?
From what i see those two could be a problem as they have default true
:
// SkipNodesWithSystemPods makes cluster autoscaler skip scale-down of nodes with non-DaemonSet pods in the kube-system namespace.
// Default: true
SkipNodesWithSystemPods *bool `json:"skipNodesWithSystemPods,omitempty"`
// SkipNodesWithLocalStorage makes cluster autoscaler skip scale-down of nodes with local storage.
// Default: true
SkipNodesWithLocalStorage *bool `json:"skipNodesWithLocalStorage,omitempty"`
If I remember correctly it was SkipNodesWithLocalStorage
that we tried to set to false. Right @peter-svensson ?
But in general it's any value where the default-value is different than the zero-value.
I see two options here:
I feel more comfortable with the first approach, it shifts some work on the end user side but it has the advantage of being explicit.
@argoyle @peter-svensson sorry for taking so long, i opened #346 to fix the case with bool fields when default is true
.
i'll cut a new alpha tonight, let me know if it fixes your issue and/or if there are other cases to cover 🤞
v1.21.0-alpha.5
should be available in a couple of minutes.
Tested the autoscaler and it seems to work just fine at least 👍
@peter-svensson @argoyle can we close the issue ?
I would say so. We'll open another one if we find anything else. Thanks for your work! ❤️
Thanks. Yes, don't hesitate to open issues, it helps improving the provider 🙏
The creation of cluster (and perhaps other ) configs are not handling golang zero values. The zero value for a
bool
isfalse
and the parameters set in the terraform files withfalse
are not propagated to the kops configuration.For example:
Renders correctly to:
However:
Renders to:
This happens for all settings that I've tested, which more or less breaks every cluster.