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

Float number are used in diff #27305

Closed
yegle opened this issue Dec 16, 2020 · 2 comments
Closed

Float number are used in diff #27305

yegle opened this issue Dec 16, 2020 · 2 comments
Labels
bug new new issue not yet triaged

Comments

@yegle
Copy link

yegle commented Dec 16, 2020

See also: hashicorp/terraform-provider-google#7988

Terraform Version

0.14.2

Terraform Configuration Files

https://github.com/google/exposure-notifications-verification-server/blob/d9e2329c9214f9fe16701e557e7a1f08e3547e73/terraform/alerting/monitoring.tf#L15-L21

Debug Output

https://gist.github.com/f2778accd1ad35d7536e6534096200ef

Crash Output

Expected Behavior

No diff when running the second terraform apply

Actual Behavior

Got the following diff

  # module.en-alerting.google_monitoring_dashboard.verification-server will be updated in-place
  ~ resource "google_monitoring_dashboard" "verification-server" {
      ~ dashboard_json = jsonencode(
          ~ {                             
              - etag        = "271a84cae5c15075542aa27c2ab5c9a6" -> null
              ~ gridLayout  = {      
                  ~ widgets = [                      
                      ~ {                
                          ~ xyChart = {
                              ~ thresholds   = [
                                  ~ {
                                      ~ value = 0.9950000047683716 -> 0.995
                                        # (1 unchanged element hidden)
                                    },
                                ]
                                # (2 unchanged elements hidden)
                            }
                            # (1 unchanged element hidden)
                        },

Steps to Reproduce

  1. Follow https://github.com/google/exposure-notifications-verification-server/blob/main/terraform/README.md#production-setup
  2. Run terraform apply
  3. Run terraform apply again

Additional Context

References

@yegle yegle added bug new new issue not yet triaged labels Dec 16, 2020
@jbardin
Copy link
Member

jbardin commented Dec 17, 2020

Hi @yegle

Thanks for filing the issue. Terraform handles numbers as multi-precision floating point values internally, as opposed to double precision floats. The diff shown indicates that the provider is returning the specific value 0.9950000047683716, while the configuration still contains 0.995.

Since you mention that this appears in conjunction with 0.14, it is possibly somehow related to hashicorp/terraform-plugin-sdk#655 in the SDK. It's also possible that the remote API itself is returning that value, in which case the provider would need to suppress the diff before returning it to terraform.

Since terraform is not creating the 0.9950000047683716 value, there's not much we can do here, so I'm going to close this for now. Progress on the SDK issue may help shed some light on the problem, but the investigation really needs to start in the provider to compare what is being returned by the resource.

Thanks!

@ghost
Copy link

ghost commented Jan 17, 2021

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.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants