You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Error message comes in when you comment the first horizontal pod autoscaler resource and then comment out the second one causing a Patch
Debug Output
╷
│ Error: Failed to update horizontal pod autoscaler: HorizontalPodAutoscaler.autoscaling "my-app-hpa" is invalid: [spec.metrics[0].type: Required value: must specify a metric source type, spec.metrics[0].type: Unsupported value: "": supported values: "ContainerResource", "External", "Object", "Pods", "Resource"]
│
│ with kubernetes_horizontal_pod_autoscaler_v2beta2.test,
│ on main.tf line 235, in resource "kubernetes_horizontal_pod_autoscaler_v2beta2" "test":
│ 235: resource "kubernetes_horizontal_pod_autoscaler_v2beta2" "test" {
│
╵
Expected Behavior
Should Patch normally and have only one metric being the External Type
Actual Behavior
We get an error that says a type is invalid due to their being an empty string for type, when looking at the trace you can see that it actually attempts to Patch with two metric blocks. One metric config from the tfconfig and another metric that's completely empty and not part of the tfconfig. The empty metric addition is what's causing this error. Their should only be one metric being Patch and not two.
Steps to Reproduce
terraform apply
comment out the first horizontal pod resource then uncomment the second horizontal pod resource in the tfconfig
Just to adding some more context as it might be the same issue.
When the Set schema contains a Map element and the state contains that scheme but tfconfig does not contain, call d.Get() on a set, there will be a zero value element in the returned set.
here is some diagnostic context:
in the above case, d.get() is returned in this road: d.get() <- d.multiReader.ReadFieldMerge() <- DiffFieldReader.ReadField() <- DiffFieldReader.readSet()
inside DiffFieldReader.readSet(), it does not ignore the *.% field code link (might be the root cause?)
then, the following code will read the already removed set, which will get zero values with Exists==true
the 3. result is different from the zero value check of d.get(), then the bug happens.
I'm not sure the diagnostic is 100% correct but just hope it could help with bugfix.
ziyeqf
added a commit
to ziyeqf/terraform-provider-azurerm
that referenced
this issue
Nov 8, 2023
SDK version
Relevant provider source code
Terraform Configuration Files
The Error message comes in when you comment the first horizontal pod autoscaler resource and then comment out the second one causing a Patch
Debug Output
╷
│ Error: Failed to update horizontal pod autoscaler: HorizontalPodAutoscaler.autoscaling "my-app-hpa" is invalid: [spec.metrics[0].type: Required value: must specify a metric source type, spec.metrics[0].type: Unsupported value: "": supported values: "ContainerResource", "External", "Object", "Pods", "Resource"]
│
│ with kubernetes_horizontal_pod_autoscaler_v2beta2.test,
│ on main.tf line 235, in resource "kubernetes_horizontal_pod_autoscaler_v2beta2" "test":
│ 235: resource "kubernetes_horizontal_pod_autoscaler_v2beta2" "test" {
│
╵
Expected Behavior
Should Patch normally and have only one metric being the
External
TypeActual Behavior
We get an error that says a type is invalid due to their being an empty string for
type
, when looking at the trace you can see that it actually attempts to Patch with two metric blocks. One metric config from the tfconfig and another metric that's completely empty and not part of the tfconfig. The empty metric addition is what's causing this error. Their should only be one metric being Patch and not two.Steps to Reproduce
terraform apply
terraform apply
References
diff.GetOk
returnnil
for the value ofTypeList
defined inTypeSet
#1197The text was updated successfully, but these errors were encountered: