-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Errors disabling google_compute_region_backend_service.log_config #12582
Comments
@AdamMAtWork I see the provider sending the related data to API. I wonder if there is a rule that the config does not follow. Are you able to disable it (problem#2) via other tools?
|
Yes, the Google REST API accepts the following logConfig with a value of false:
Submitting this to the update endpoint results in a success message. |
@edwardmedia
|
@AdamMAtWork we should be able to update the sampleRate to 0, but I am not able to update the enable from
|
@AdamMAtWork closing this issue. I believe this is by design |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
It's not currently possible to disable logging on a google_compute_region_backend_service resource, once it has been enabled with a non-zero sample rate.
Affected provider versions: 3.54, 4.36
If I create a
, the resource is created with logging disabled. This is working as expected.
If I then update the resource using
then the log_config is enabled, but the sample_rate remains zero. This completes successfully, although serves no purpose as a sampling rate above zero is required. So, let's set it to some useful value:
This sets the sampling_rate to 25%, and applies as expected.
So far, so good.
But now, we need to disable the logging. So we try:
This results in the following error:
In an attempt to get around this, let's try setting the sampling_rate to zero first, and then setting enabled to false:
This takes about 30s to complete while the API processes the request, and completes without any errors. However, it seems the value of zero is ignored by the API, as the next plan indicates the same change still needs to be applied:
Repeating this test with
sample_rate = null
yields an identical result.This exposes 2 problems:
sample_rate
to zero or null once it has been set to any non-zero valueenable
to false as the provider produces a log_config object that always includes thesample_rate
value.A review of the provider code file
resource_compute_region_backend_service.go
reveals the following function which appears to be responsible for producing the value of the log_config object:I'm a long-time software developer, but am not super familier with golang, so my assessment is probably inaccurate, but in this function, the expansion of the value for sample rate appears to contain the following errors:
!isEmptyValue(val)
will always be true, sinceisEmptyValue(val)
will always be false - a number value will always have a value because there is no way in HCL or json to express an empty number. Unlike an empty string, which is quoted, numbers are not quoted. If I try to provide the value 'null', it is either ignored by the API or the provider is sending the previous value.sample_rate
should not be sent at all if the value ofenable
is false, but the tests deciding whether to includesample_rate
omit this check. An extra check, something like the following, is missing:The text was updated successfully, but these errors were encountered: