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

Fix paginated remote state consumers #367

Merged
merged 3 commits into from
Sep 23, 2021

Conversation

chrisarcand
Copy link
Member

@chrisarcand chrisarcand commented Sep 16, 2021

Closes #366

Description

Previously, any number of remote state consumers over a standard page (20 results) would cause a subsequent plan to try and continue adding the list of consumer IDs indefinitely, as the Read implementation didn't take pagination in to account.

I also bumped the page size for these requests to the maximum (100), as for large Terraform Enterprise installations it could be relatively common to map out hundreds of workspaces as consumers of one.

Testing plan

Create a configuration that adds several remote state consumers to a single workspace. The subsequent plan should be empty, and not look like the following failing test case demonstrating the problem:

=== RUN   TestAccTFEWorkspace_paginatedRemoteStateConsumers
    resource_tfe_workspace_test.go:938: Step 1/1 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout


        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # tfe_workspace.foobar will be updated in-place
          ~ resource "tfe_workspace" "foobar" {
                id                            = "ws-Q1G4EkdGGsXca1aS"
                name                          = "workspace-test"
              ~ remote_state_consumer_ids     = [
                  + "ws-4o4muNBQguRjwKwX",
                  + "ws-6dLeBoU7hNKueY21",
                  + "ws-JuCiwfb2bz9UN8zk",
                  + "ws-VhDnvHgiq1kAHWi7",
                  + "ws-hMKogwof5GhdQHqT",
                    # (20 unchanged elements hidden)
                ]
                # (13 unchanged attributes hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccTFEWorkspace_paginatedRemoteStateConsumers (15.95s)

@chrisarcand chrisarcand force-pushed the fix-paginated-remote-state-consumers branch 3 times, most recently from 9a57519 to 4eba439 Compare September 21, 2021 02:36
Previously, any number of remote state consumers over a standard page
(20 results) would cause a subsequent plan to try and continue adding
the list of consumer IDs indefinitely, as the Read implementation didn't
take pagination in to account.
We're already using 1.17, and just forgot to update this reference.
@chrisarcand chrisarcand force-pushed the fix-paginated-remote-state-consumers branch from 4eba439 to 61f1f3e Compare September 21, 2021 02:51
@chrisarcand chrisarcand marked this pull request as ready for review September 21, 2021 03:05
@chrisarcand chrisarcand requested a review from a team as a code owner September 21, 2021 03:05
@chrisarcand chrisarcand merged commit 315719b into main Sep 23, 2021
@chrisarcand chrisarcand deleted the fix-paginated-remote-state-consumers branch September 23, 2021 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tfe_workspace - remote_state_consumer_ids showing unnecessary change when greater than 20
2 participants