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

permadiff caused by "added support for keepalive_interval to google_compute_router.bgp" #11268

Open
red8888 opened this issue Mar 14, 2022 · 12 comments

Comments

@red8888
Copy link

red8888 commented Mar 14, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.14.4

  • provider registry.terraform.io/hashicorp/aws v4.5.0
  • provider registry.terraform.io/hashicorp/google v4.13.0
  • provider registry.terraform.io/hashicorp/google-beta v4.13.0

Affected Resource(s)

google_compute_router

From the last release:
https://github.com/hashicorp/terraform-provider-google-beta/releases/tag/v4.13.0
hashicorp/terraform-provider-google-beta#4089

Terraform Configuration Files

If I create a google_compute_router and don't include a keepalive_interval property I see a permadiff for:
keepalive_interval = 0 -> 20

b/305197736

@red8888 red8888 added the bug label Mar 14, 2022
@koalalorenzo
Copy link
Contributor

Same issue, we even defined keepalive_interval = 20 but it keeps showing in our plans.

@megan07 megan07 self-assigned this Mar 15, 2022
@megan07
Copy link
Contributor

megan07 commented Mar 15, 2022

Hi @red8888 and @koalalorenzo, I'm sorry you are running into this. Unfortunately I haven't been able to reproduce this with my current configurations, would one of you mind sharing your configuration please? Thanks!

@leighst-anchorage
Copy link

leighst-anchorage commented Mar 16, 2022

We're also hitting this. Sharing our full configuration is tough. But here's the defn for the resource in question, very simple

resource "google_compute_router" "router" {
  name = "default-${var.region}-router"

  region  = var.region
  network = var.network

  bgp {
    asn = <redacted>
  }
}

And heres what we're seeing in terraorm

Terraform will perform the following actions:

  # module.anchorage_root.google_compute_router.router will be updated in-place
  ~ resource "google_compute_router" "router" {
        id                            = "us-west1/default-router"
        name                          = "default-router"
        # (6 unchanged attributes hidden)

      ~ bgp {
          ~ keepalive_interval = 0 -> 20
            # (3 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }

Just based on your understand of the code base, do you have any idea why this would be getting set? Seems bizarre. Note, it does not help to override this value by setting it to 0, 20, 21 or etc.

One thing to note: when i set the keepalive property manually in gcp console, it seems to accept it, but then when I returned, it was not set. Maybe some gcp bug?

@megan07
Copy link
Contributor

megan07 commented Mar 16, 2022

@leighst-anchorage thank you for sharing your config! I was able to reproduce this. The issue is that keepalive_interval was added in the 4.13.0 version of the provider with a default value of 20, so if the router was created in an older version, then upgrading to this version will now write that value to state, so terraform is showing that diff.

After doing some testing, I noticed this wouldn't show a diff in older versions of Terraform, but as I reached out to others, with the new diffing in Terraform 1.0, this is expected. It should be safe to apply as 20 is the default in GCP.

To further clarify why overriding it doesn't help is that Terraform 1.0 will show 2 diffs, first, the changes made "outside Terraform" (the changes made outside your configuration - which is this change) and the second is the changes your configuration is proposing. You'll notice the first diff shows the change to 20 and the second diff will show 20 changing to whatever override is in your config.

Let me know if you have further questions or if you're still encountering the issue after apply. Thanks!

@jmymy
Copy link

jmymy commented Apr 27, 2022

Having the same issue. The apply doesnt do anything and on the next run, permadiff again.

@dave-pollock
Copy link

I was able to work around the issue by applying a different keepalive_interval value (in my case, I set it to 21), and then changing it back to 20. The value of 20 was then stored against the router in GCP and the diff was no longer detected.

@jamesnicolas
Copy link

jamesnicolas commented May 30, 2022

I'm having the same issue as well, even after applying in terraform v1.0.11. I've tried removing it from the state and importing it, applying with -refresh-only, and setting keepalive_interval to 20, but for some reason terraform keeps thinking the keepalive_interval is 0. I haven't tried @dave-pollock's workaround yet as I'm trying to find less disruptive solutions, but it might be the only fix.

Update: got impatient and tried the above workaround and it's working fine now

@dantheperson
Copy link

same for me. For anyone using this via the cloud-nat module, the setting is
router_keepalive_interval = 20

i set it first to 21, then back to 20, not sure if that was required.

@woohgit
Copy link

woohgit commented Jul 14, 2022

It looks like it's caused by terraform not applying "default' values. Yeah the bump to 21 and revert back to 20 works as if it's not a default value, terraform applies it properly and most importantly it writes it to the statefile.

@pietrodn
Copy link

pietrodn commented Oct 7, 2022

You can even set it to 21 through the UI and let Terraform set it back to 20 to resolve the permadiff.
This is the link:

https://console.cloud.google.com/hybrid/routers/list

@craiggunson
Copy link

Setting it to 21 worked for me.

@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-router labels Sep 11, 2023
@edwardmedia edwardmedia removed the forward/review In review; remove label to forward label Sep 14, 2023
@akshat-jindal-nit
Copy link

akshat-jindal-nit commented Jan 15, 2025

I working on this particular issue .
Here what i founds ,
1 . By using the terraform version 3.28.0
Router Config

resource "google_compute_router" "router" {
  name    = "tf-test-my-router-arcus-router-akshat"
  region  = google_compute_subnetwork.subnetwork.region
  network = google_compute_network.network.self_link
  bgp {
    asn = 64514
  }
}
  1. Upgrading TF version to 4.13.0v. using terraform init -upgrade
  2. terraform plan -refresh=false
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # google_compute_router.router will be updated in-place
  ~ resource "google_compute_router" "router" {
        id                 = "projects/vpn-test-project-422614/regions/us-central1/routers/tf-test-my-router-arcus-router-akshat"
        name               = "tf-test-my-router-arcus-router-akshat"
        # (5 unchanged attributes hidden)

      ~ bgp {
          + advertised_groups  = []
          + keepalive_interval = 20
            # (2 unchanged attributes hidden)
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

As keepalive_interval support is added in TF 4.13.0v. It is expected to give the diff whenever we upgrade the state.
4. terraform plan

No changes. Your infrastructure matches the configuration.
  1. refresh state using terraform apply
google_compute_network.network: Refreshing state... [***]
google_compute_subnetwork.subnetwork: Refreshing state... [***]
google_compute_router.router: Refreshing state... [***]

No changes. Your infrastructure matches the configuration.
  1. terraform plan -refresh=false
`No` changes. Your infrastructure matches the configuration.

As per my investigation all things are working as expected. We can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests