fix(resmgr): an imported pcd_host_cluster_role plans clean - #50
Merged
Conversation
- add TestAccResmgrHostClusterRoleImport (resmgr_test.go), gated on PCD_ACC_RESMGR and PCD_ACC_HOST_ID, with a polling testAccCheckHostClusterRoleDestroy since deauthorising a role is asynchronous - note in roleOptionsChanged's doc comment that the comparison is deliberately role-agnostic: ForceNew role plus ValidateConfig's option-to-role pairing means a mismatch can only push toward sending the PUT, never toward silently skipping one - TestUpdateSkipsResmgrForClientSideChanges now also asserts host_cluster survived the short-circuit, and documents why the response state is seeded from prior rather than a null root
- CHANGELOG: the Unreleased fixed-entry now says a false -> true flip on an already-assigned role no longer waits for convergence either (previously it PUT and then waited), and names taint / apply -replace as the way to force a wait - plan: record in Self-Review that the acceptance test was added at final review by user decision, so the plan and the branch agree
…role-import # Conflicts: # CHANGELOG.md
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Importing a
pcd_host_cluster_rolealways left the next plan with one change:and applying it re-PUT the role assignment to resmgr for a change resmgr never sees. Found while importing the CE lab's roles for the PCD-9783 destroy test (the imports had to be done with the CLI to avoid the PUTs).
Root cause
wait_until_convergedisOptional + Computed + Default(false).ImportStateset onlyid,host_idandrole, andReadnever touches the flag, so the imported state heldnull; the schema default then plannednull -> false.UpdatePUT unconditionally, so applying that diff was a real write.lifecycle { ignore_changes }cannot suppress a provider-side default.Change
ImportStatewriteswait_until_converged = false, so the imported state already equals what the default will plan.Updatecompares the two server-side options,host_clusterandbackends, between plan and prior state through a pure helperroleOptionsChanged(null and""host cluster are the same omitted value; backends compared as ordered lists with null/unknown as "not sent" and[]as a value, mirroring what the PUT body carries). When nothing server-side changed it stores the plan and returns: no PUT, no convergence wait. A real change takes the untouched path.false) see no upgrade diff.host_clusterandbackendsare still not read back; a configuration that sets them on an imported role plans the update it always did.false -> trueon an already-assigned role no longer re-PUTs and waits; taint or-replaceto block on an existing role.Design spec and implementation plan are committed under
docs/superpowers/.Verification
roleOptionsChanged;Updateno-op test through the framework request types with a nil client, so any regression that reaches resmgr fails;ImportStatetests through a schema-builttfsdk.State(the same null-root construction the framework uses).TestAccResmgrHostClusterRoleImport, gated byPCD_ACC_RESMGR=1andPCD_ACC_HOST_ID, creates the role, imports it withImportStateVerify(which fails on the pre-fix provider because the imported state lacked the flag), and polls the host after destroy until the role clears. Ran green against the CE lab (2026.4, host 136fc11a, roleimage-library) in 65s.gofmt,go vet,golangci-lint(0 issues),go test ./internal/...green.ImportStatePersistthat made Terraform refuse the import ("Resource already managed").Follow-up, not in this PR:
Updatecarries its own copy ofassignBody's body-building becauseassignBodytakes a*resource.CreateResponse; changing it to take*diag.Diagnosticswould let both paths share one function.