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

PlanResourceChange issue with empty strings and GCP labels #2078

Closed
VenelinMartinov opened this issue Jun 10, 2024 · 2 comments · Fixed by #2072
Closed

PlanResourceChange issue with empty strings and GCP labels #2078

VenelinMartinov opened this issue Jun 10, 2024 · 2 comments · Fixed by #2072
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@VenelinMartinov
Copy link
Contributor

What happened?

Testing GCP under PRC yielded failures in the label-related tests:

--- FAIL: TestLabelsCombinationsGo (0.00s)
    --- FAIL: TestLabelsCombinationsGo/convoluted_test_case_found_by_random-sampling (14.78s)
        examples_go_test.go:339: state1 = {"defaultLabels":{"x":"","y":"s"},"labels":{"x":""}}
        examples_go_test.go:340: state2 = {"defaultLabels":{"x":""},"labels":{"x":"","y":""}}
        program.go:1946: sample: labels-combinations-go
        program.go:1951: pulumi: /opt/homebrew/bin/pulumi
        command.go:46: **** Invoke '/opt/homebrew/Cellar/go/1.22.4/libexec/bin/go mod edit -replace github.com/pulumi/pulumi-gcp/sdk/v7=/Users/vvm/code/pulumi-gcp/sdk' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:121: Command completed without output
        command.go:46: **** Invoke '/opt/homebrew/Cellar/go/1.22.4/libexec/bin/go mod tidy' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:121: Command completed without output
        program.go:2096: projdir: /Users/vvm/go/src/stackName-1718038390063176000-941040
        program.go:1336: Initializing project (dir /Users/vvm/go/src/stackName-1718038390063176000-941040; stack p-it-venelins-m-labels-com-d923da9f)
        command.go:46: **** Invoke '/opt/homebrew/bin/pulumi login --cloud-url file:///var/folders/82/nqnqw81s1h56l5nv940f9mq00000gn/T/TestLabelsCombinationsGoconvoluted_test_case_found_by_random-sampling649358922/001' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:118: Wrote output to /Users/vvm/go/src/stackName-1718038390063176000-941040/command-output/pulumi-login.20240610-175310.1ca80.log
        command.go:46: **** Invoke '/opt/homebrew/bin/pulumi stack init p-it-venelins-m-labels-com-d923da9f' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:118: Wrote output to /Users/vvm/go/src/stackName-1718038390063176000-941040/command-output/pulumi-stack-init.20240610-175311.32536.log
        command.go:46: **** Invoke '/opt/homebrew/bin/pulumi config set-all --plaintext state2={"defaultLabels":{"x":""},"labels":{"x":"","y":""}} --plaintext gcp:config:project=pulumi-development --plaintext gcp:config:zone=us-west1-a --plaintext gcp:config:region=us-west1 --plaintext state1={"defaultLabels":{"x":"","y":"s"},"labels":{"x":""}}' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:121: Command completed without output
        program.go:1503: Performing primary preview and update
        command.go:46: **** Invoke '/opt/homebrew/bin/pulumi up --non-interactive --yes --skip-preview --event-log /var/folders/82/nqnqw81s1h56l5nv940f9mq00000gn/T/p-it-venelins-m-labels-com-d923da9f-events.json' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:118: Wrote output to /Users/vvm/go/src/stackName-1718038390063176000-941040/command-output/pulumi-update-initial.20240610-175322.f2563.log
        command.go:46: **** Invoke '/opt/homebrew/bin/pulumi stack export --file /var/folders/82/nqnqw81s1h56l5nv940f9mq00000gn/T/p-it-venelins-m-labels-com-d923da9f1574371746/stack.json' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:121: Command completed without output
        program.go:1890: Performing extra runtime validation.
        examples_go_test.go:402: phase: 1
        examples_go_test.go:403: state1: {"defaultLabels":{"x":"","y":"s"},"labels":{"x":""}}
        examples_go_test.go:407:
            	Error Trace:	/Users/vvm/code/pulumi-gcp/examples/examples_go_test.go:407
            	            				/Users/vvm/go/pkg/mod/github.com/pulumi/pulumi/pkg/[email protected]/testing/integration/program.go:1891
            	            				/Users/vvm/go/pkg/mod/github.com/pulumi/pulumi/pkg/[email protected]/testing/integration/program.go:1533
            	Error:      	Not equal:
            	            	expected: map[string]string{"x":"", "y":"s"}
            	            	actual  : map[string]string{"y":"s"}
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1,3 +1,2 @@
            	            	-(map[string]string) (len=2) {
            	            	- (string) (len=1) "x": (string) "",
            	            	+(map[string]string) (len=1) {
            	            	  (string) (len=1) "y": (string) (len=1) "s"
            	Test:       	TestLabelsCombinationsGo/convoluted_test_case_found_by_random-sampling
            	Messages:   	key=bucket
        program.go:1461: Destroying stack
        command.go:46: **** Invoke '/opt/homebrew/bin/pulumi destroy --non-interactive --yes --skip-preview' in '/Users/vvm/go/src/stackName-1718038390063176000-941040'
        command.go:118: Wrote output to /Users/vvm/go/src/stackName-1718038390063176000-941040/command-output/pulumi-destroy.20240610-175324.75a32.log
        program.go:1477: Test failed, retaining stack 'p-it-venelins-m-labels-com-d923da9f'

Example

TestLabelsCombinationsGo

PATH=~/code/pulumi-gcp/bin:$PATH PULUMI_ENABLE_PLAN_RESOURCE_CHANGE=1 go test -run TestLabelsCombinationsGo -tags=all

Output of pulumi about

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@VenelinMartinov VenelinMartinov added needs-triage Needs attention from the triage team kind/bug Some behavior is incorrect or out of spec labels Jun 10, 2024
@VenelinMartinov VenelinMartinov removed the needs-triage Needs attention from the triage team label Jun 11, 2024
@VenelinMartinov VenelinMartinov self-assigned this Jun 11, 2024
@VenelinMartinov
Copy link
Contributor Author

Minimised the repro in #2072.

Looks like empty strings don't replace a non-empty label. Will check if present in TF.

@VenelinMartinov
Copy link
Contributor Author

Yup, this reproes in TF:

provider "google" {
  region       = "us-central1"
}

resource "google_storage_bucket" "bucket" {
  name     = "example-bucket123123223"
  location = "US"
  labels = {
    environment = "dev" //change this to ""
  }
}

changing the environment label changes labels in state to the desired value but not effective_labels and the cloud value stays as before.

@VenelinMartinov VenelinMartinov transferred this issue from pulumi/pulumi-terraform-bridge Jun 12, 2024
VenelinMartinov added a commit that referenced this issue Jun 13, 2024
During PlanResourceChange these tests was discovered to fail. Looks like
this is actually an upstream bug - the provider takes empty string for a
label to mean "keep previous value". This was reproed in TF.

I've adjusted the tests to take this into account - they should now work
for both PRC and non-PRC. We can remove the non-PRC bit after enabling
PRC by default.

fixes #2078
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants