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: Add DiffSuppressFunc on argocd_cluster.server #353

Merged

Conversation

mkilchhofer
Copy link
Collaborator

While working on this PR here:

, I saw that the build is already broken on master branch:
image

It seems that the test is failing due to inconsistent handling of a trailing /.

=== RUN   TestAccArgoCDCluster_invalidSameServer
    resource_argocd_cluster_test.go:275: Step 3/3, expected an error with pattern, no match on: After applying this test step, 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:
        
          # argocd_cluster.cluster_with_trailing_slash will be updated in-place
          ~ resource "argocd_cluster" "cluster_with_trailing_slash" {
                id     = "https://kubernetes.default.svc.cluster.local/server"
                name   = "server"
              ~ server = "https://kubernetes.default.svc.cluster.local/" -> "https://kubernetes.default.svc.cluster.local/"
                # (1 unchanged attribute hidden)
        
                # (1 unchanged block hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
    testing_new.go:82: Error running post-test destroy, there may be dangling resources: exit status 1
        
        Error: failed to delete cluster https://kubernetes.default.svc.cluster.local/server
        
        rpc error: code = PermissionDenied desc = permission denied

I am not familiar with the provider internals here but it seems that putting a diff-ignore function could help here. It is already present on the cluster create function:
https://github.com/oboukili/terraform-provider-argocd/blob/b42b92267a212b108537caf32a462c133f21813d/argocd/resource_argocd_cluster.go#L55

FYI @onematchfox

@onematchfox
Copy link
Collaborator

Thanks for opening this up. That test is notoriously flaky and has been a bother for quite some time. There is, however, already some handling for this case here. That said, this approach may be the better option. Unfortunately, I don't really have the bandwidth to give it the consideration it requires at this point. So, I hope you don't mind this PR languishing for a little while until I can do so. Have merged your other PR and will ensure that that fix is released ASAP.

@mkilchhofer
Copy link
Collaborator Author

mkilchhofer commented Nov 19, 2023

That test is notoriously flaky and has been a bother for quite some time. There is, however, already some handling for this case here. That said, this approach may be the better option.

What I tested is this here manually with the provider version 6.0.3:

$ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # argocd_cluster.cluster_with_trailing_slash will be created
  + resource "argocd_cluster" "cluster_with_trailing_slash" {
      + id     = (known after apply)
      + info   = (known after apply)
      + name   = "server"
      + server = "https://kubernetes.default.svc.cluster.local/"

      + config {
          + bearer_token = (sensitive value)

          + tls_client_config {
              + ca_data  = <<-EOT
                    -----BEGIN CERTIFICATE-----
                    REDACTED
                    -----END CERTIFICATE-----
                EOT
              + insecure = false
            }
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

argocd_cluster.cluster_with_trailing_slash: Creating...
argocd_cluster.cluster_with_trailing_slash: Creation complete after 2s [id=https://kubernetes.default.svc.cluster.local/server]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

and plan again:

$ terraform apply
argocd_cluster.cluster_with_trailing_slash: Refreshing state... [id=https://kubernetes.default.svc.cluster.local/server]

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:

  # argocd_cluster.cluster_with_trailing_slash will be updated in-place
  ~ resource "argocd_cluster" "cluster_with_trailing_slash" {
        id         = "https://kubernetes.default.svc.cluster.local/server"
        name       = "server"
      ~ server     = "https://kubernetes.default.svc.cluster.local" -> "https://kubernetes.default.svc.cluster.local/"
        # (2 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value:

Since the remove of trailing / is handled inside the Create function only, the diffing doesn't work properly.
I think can also be handled inside the read function but it is probably easier to only handle it like my proposal and maybe we can also remove the special handling you mentioned :)

Copy link

github-actions bot commented Dec 4, 2023

This pr is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Dec 4, 2023
@onematchfox onematchfox removed the Stale label Dec 4, 2023
Copy link

This pr is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Dec 19, 2023
@mkilchhofer
Copy link
Collaborator Author

not stale. ping @onematchfox

@github-actions github-actions bot removed the Stale label Dec 20, 2023
Copy link

github-actions bot commented Jan 3, 2024

This pr is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jan 3, 2024
@onematchfox
Copy link
Collaborator

Not stale... Been away. Hoping to get around to this soon.

@github-actions github-actions bot removed the Stale label Jan 8, 2024
Copy link

This pr is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jan 22, 2024
@mkilchhofer
Copy link
Collaborator Author

not stale

@github-actions github-actions bot removed the Stale label Jan 23, 2024
Copy link
Collaborator

@onematchfox onematchfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in getting to this. Such a small change. I hate that we need to do this but I do think it will do the job until such time as we look at migrating this resource to the plugin framework where we can look at custom types (e.g. URL) which provide a mechanism for checking semantic equality.

@onematchfox onematchfox merged commit b684013 into argoproj-labs:master Feb 5, 2024
6 checks passed
onematchfox added a commit that referenced this pull request Mar 23, 2024
…urce (#357)

* feat(argocd_applicationset): add ignore_application_differences attribute

* feat(argocd_applicationset): remove unnecessary if condition

* doc(argocd_applicationset): fix documentation application_set

* chores(argocd): add ArgoCD 2.9.3 to matrix test

* build(deps): Bump github.com/go-git/go-git/v5 from 5.7.0 to 5.11.0 (#361)

Bumps [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) from 5.7.0 to 5.11.0.
- [Release notes](https://github.com/go-git/go-git/releases)
- [Commits](go-git/go-git@v5.7.0...v5.11.0)

---
updated-dependencies:
- dependency-name: github.com/go-git/go-git/v5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): Bump github.com/argoproj/argo-cd/v2 from 2.8.3 to 2.8.8 (#365)

Bumps [github.com/argoproj/argo-cd/v2](https://github.com/argoproj/argo-cd) from 2.8.3 to 2.8.8.
- [Release notes](https://github.com/argoproj/argo-cd/releases)
- [Changelog](https://github.com/argoproj/argo-cd/blob/master/CHANGELOG.md)
- [Commits](argoproj/argo-cd@v2.8.3...v2.8.8)

---
updated-dependencies:
- dependency-name: github.com/argoproj/argo-cd/v2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: Add DiffSuppressFunc on argocd_cluster.server (#353)

* build(deps): Bump golang.org/x/crypto from 0.14.0 to 0.17.0 (#358)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0.
- [Commits](golang/crypto@v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): Bump github.com/cloudflare/circl from 1.3.3 to 1.3.7 (#364)

Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.3.3 to 1.3.7.
- [Release notes](https://github.com/cloudflare/circl/releases)
- [Commits](cloudflare/circl@v1.3.3...v1.3.7)

---
updated-dependencies:
- dependency-name: github.com/cloudflare/circl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps-dev): bump test versions of ArgoCD to latest patch versions

* build(deps-dev): bump test versions of k8s

* build(deps): bump github.com/argoproj/argo-cd/v2 from 2.9.3 to 2.9.9

* build(deps): bump k8s modules to align with argocd version

* fix: call cluster list endpoint with trimmed server

* fix: add diff suppression for empty sync policy on application

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marco Maurer (-Kilchhofer) <mkilchhofer@users.noreply.github.com>
Co-authored-by: Brian Fox <brian.fox@embark-studios.com>
@mkilchhofer mkilchhofer deleted the bugfix/fix_testing_on_2.8 branch March 24, 2024 21:46
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.

2 participants