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

Don't force new argocd_application_set resource when adding/removing match_expressions #331

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

ahublersos
Copy link
Contributor

Fixes (#330).

This PR removes ForceNew: true from the matchExpressionsSchema() allowing match expressions to be added and removed without destroying the argocd_application_Set resource.

After making the changes, I see a handful of tests failing. Some, like TestAccArgoCDRepositoryCertificatesSSH_WithApplication, TestAccArgoCDRepositoryCredentials, and TestAccArgoCDApplicationSet_matrixInvalid fail even without the changes in this PR. TestAccArgoCDApplicationSet_mergeInvalid and TestAccArgoCDApplicationSet_generatorTemplate begin failing once ForceNew: true is removed and I can't seem to figure out how they are connected tomatchExpressionsSchema().

Here are the test failures:
--- The first two tests only fail once ForceNew: true has been removed from matchExpressionsSchema().

=== CONT  TestAccArgoCDApplicationSet_mergeInvalid # Not present without change
    resource_argocd_application_set_test.go:718: Step 1/3, expected an error with pattern, no match on: Error running pre-apply refresh: exit status 1

        Error: Not enough list items

          on terraform_plugin_test.tf line 9, in resource "argocd_application_set" "merge_insufficient_generators":
           9: 			merge {

        Attribute spec.0.generator.0.merge.0.generator requires 2 item minimum, but
        config has only 1 declared.
--- FAIL: TestAccArgoCDApplicationSet_mergeInvalid (0.91s)
=== CONT  TestAccArgoCDApplicationSet_generatorTemplate # Not present without change
    resource_argocd_application_set_test.go:739: Step 1/2 error: Error running apply: exit status 1

        Error: failed to create application set generator-template

          on terraform_plugin_test.tf line 2, in resource "argocd_application_set" "generator_template":
           2: resource "argocd_application_set" "generator_template" {

        rpc error: code = Internal desc = grpc: failed to unmarshal the received
        message: unexpected EOF
--- FAIL: TestAccArgoCDApplicationSet_generatorTemplate (7.17s)

--- The tests below fail every time, even running from master with no changes.

=== RUN   TestAccArgoCDRepositoryCertificatesSSH_WithApplication
    resource_argocd_repository_certificate_test.go:207: Step 1/1 error: After applying this test step, the plan was not empty.
        stdout:


        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # argocd_repository.private will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-1.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccArgoCDRepositoryCertificatesSSH_WithApplication (42.53s)
=== RUN   TestAccArgoCDRepositoryCredentials
    resource_argocd_repository_credentials_test.go:19: Step 4/4 error: After applying this test step, the plan was not empty.
        stdout:


        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # argocd_repository.private[0] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-1.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[1] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-2.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[2] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-3.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[3] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-4.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[4] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-5.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[5] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-6.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[6] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-7.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[7] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-8.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[8] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-9.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

          # argocd_repository.private[9] will be updated in-place
          ~ resource "argocd_repository" "private" {
                id                      = "git@private-git-repository.argocd.svc.cluster.local:~/project-10.git"
              - username                = "git" -> null
                # (6 unchanged attributes hidden)
            }

        Plan: 0 to add, 10 to change, 0 to destroy.
=== CONT  TestAccArgoCDApplicationSet_matrixInvalid
    resource_argocd_application_set_test.go:262: Step 1/4, expected an error with pattern, no match on: Error running pre-apply refresh: exit status 1

        Error: Not enough list items

          on terraform_plugin_test.tf line 9, in resource "argocd_application_set" "matrix_insufficient_generators":
           9: 			matrix {

        Attribute spec.0.generator.0.matrix.0.generator requires 2 item minimum, but
        config has only 1 declared.
--- FAIL: TestAccArgoCDApplicationSet_matrixInvalid (1.00s)

@ahublersos
Copy link
Contributor Author

Looks like all the tests that were failing locally are passing in the automated PR acceptance tests.

@onematchfox
Copy link
Collaborator

@ahublersos, thanks so much for taking the time to put together this PR (and sorry for the strange issues you seem to be having).

FWIW, I had been debating whether to make ForceNew configurable as per the Kubernetes provider but since it doesn't need to be set to true in this provider I think we can leave that for another day.

Re, the failing tests: yeah, this seems weird. Have relaunched the failed actions and if all passes I'll happily approve and merge this change.

@onematchfox onematchfox changed the title Don't force new argocd_application_set resource when adding/removing match_expressions Don't force new argocd_application_set resource when adding/removing match_expressions Sep 5, 2023
@onematchfox onematchfox self-requested a review September 5, 2023 18:47
@ahublersos
Copy link
Contributor Author

@ahublersos, thanks so much for taking the time to put together this PR (and sorry for the strange issues you seem to be having).

FWIW, I had been debating whether to make ForceNew configurable as per the Kubernetes provider but since it doesn't need to be set to true in this provider I think we can leave that for another day.

Re, the failing tests: yeah, this seems weird. Have relaunched the failed actions and if all passes I'll happily approve and merge this change.

@onematchfox Thanks for sharing that link to the Kubernetes provider, I hadn't seen that pattern before. TIL!

@onematchfox onematchfox changed the title Don't force new argocd_application_set resource when adding/removing match_expressions Don't force new argocd_application_set resource when adding/removing match_expressions Sep 6, 2023
@onematchfox onematchfox merged commit d7bdd4d into argoproj-labs:master Sep 6, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding or removing match_expressions in a selector forces a new argocd_application_set resource
2 participants