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

provider/google: fix single port diff cycle #12662

Merged
merged 1 commit into from
Mar 14, 2017

Conversation

paddycarver
Copy link
Contributor

When specifying a single port in port_range, the API would accept it as
input, but would return it as {PORT}-{PORT}. Terraform would then see
this as different, even though (semantically) it's the same.

This commit adds a test that exposes the diff cycle created by this, and
an inline DiffSuppressFunc to resolve it.

Fixes #9051.

Failure of new unit test before fix applied:

=== RUN   TestAccComputeForwardingRule_singlePort
--- FAIL: TestAccComputeForwardingRule_singlePort (44.72s)
        testing.go:265: Step 0 error: After applying this step, the plan was not empty:

                DIFF:

                DESTROY/CREATE: google_compute_forwarding_rule.foobar
                  description:           "Resource created for Terraform acceptance testing" => "Resource created for Terraform acceptance testing"
                  ip_address:            "35.184.15.161" => "<computed>"
                  ip_protocol:           "UDP" => "UDP"
                  load_balancing_scheme: "EXTERNAL" => "EXTERNAL"
                  name:                  "tf-uxitnvxk70" => "tf-uxitnvxk70"
                  network:               "" => "<computed>"
                  port_range:            "80-80" => "80" (forces new resource)
                  project:               "hc-terraform-testing" => "<computed>"
                  region:                "us-central1" => "<computed>"
                  self_link:             "https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/regions/us-central1/forwardingRules/tf-uxitnvxk70" => "<computed>"
                  subnetwork:            "" => "<computed>"
                  target:                "https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/regions/us-central1/targetPools/tf-6zzlxj9y2p" => "https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/regions/us-central1/targetPools/tf-6zzlxj9y2p"

                STATE:

                google_compute_forwarding_rule.foobar:
                  ID = tf-uxitnvxk70
                  backend_service =
                  description = Resource created for Terraform acceptance testing
                  ip_address = 35.184.15.161
                  ip_protocol = UDP
                  load_balancing_scheme = EXTERNAL
                  name = tf-uxitnvxk70
                  network =
                  port_range = 80-80
                  ports.# = 0
                  project = hc-terraform-testing
                  region = us-central1
                  self_link = https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/regions/us-central1/forwardingRules/tf-uxitnvxk70
                  subnetwork =
                  target = https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/regions/us-central1/targetPools/tf-6zzlxj9y2p

                  Dependencies:
                    google_compute_target_pool.foobar-tp
                google_compute_target_pool.foobar-tp:
                  ID = tf-6zzlxj9y2p
                  backup_pool =
                  description = Resource created for Terraform acceptance testing
                  failover_ratio = 0
                  health_checks.# = 0
                  instances.# = 2
                  instances.0 = us-central1-a/foo
                  instances.1 = us-central1-b/bar
                  name = tf-6zzlxj9y2p
                  project = hc-terraform-testing
                  region = us-central1
                  self_link = https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/regions/us-central1/targetPools/tf-6zzlxj9y2p
                  session_affinity =
FAIL

Unit test after fix applied:

=== RUN   TestAccComputeForwardingRule_singlePort
--- PASS: TestAccComputeForwardingRule_singlePort (45.11s)
PASS

When specifying a single port in port_range, the API would accept it as
input, but would return it as {PORT}-{PORT}. Terraform would then see
this as different, even though (semantically) it's the same.

This commit adds a test that exposes the diff cycle created by this, and
an inline DiffSuppressFunc to resolve it.

Fixes #9051.
@paddycarver paddycarver merged commit 7a06d3f into master Mar 14, 2017
@grubernaut grubernaut deleted the paddy_9051_forwarding_rule_cycle branch May 11, 2017 00:32
@ghost
Copy link

ghost commented Apr 12, 2020

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 and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_compute_forwarding_rule isn't idempotent anymore (issue with a single port in port_range).
2 participants