Skip to content

ArgoCD clusters should list to find the cluster instead of get and check for NotFound #266

@w4rgrum

Description

@w4rgrum

Terraform Version, ArgoCD Provider Version and ArgoCD Version

Terraform version: 1.2.8
ArgoCD provider version: 5.2.0
ArgoCD version: 2.5.6

Affected Resource(s)

  • argocd_cluster

Question

Got this issue when trying to update a cluster with TF that had been previously manually deleted on ArgoCD server side:

Error: could not get cluster information: rpc error: code = PermissionDenied desc = permission denied

After some investigations on this issue I concluded this:

To retrieve a cluster from an ArgoCD server there are basically 2 ways:

  1. directly get the cluster
  2. list the clusters and look for your cluster in the returned list

However, since the implementation of argo-cd PR-7039 the 1) is not reliable as if the cluster is not found it will return a "fake" 403 instead of 404 for security reasons as the feature enabled cluster-level RBAC (see argo-cd discussion 10830)

Currently the provider uses the list api at create time: https://github.com/oboukili/terraform-provider-argocd/blob/master/argocd/resource_argocd_cluster.go#L94-L129

However for all other cases it uses a direct get and checks for NotFound (https://github.com/oboukili/terraform-provider-argocd/blob/master/argocd/resource_argocd_cluster.go#L167-L175) in order to ignore the error in that case, but this will never be returned because of the above-mentioned change.

My question is: shouldn't the provider always use the list api to retrieve a cluster to be able to properly ignore a cluster not found case? (and thus to be more robust to unexpected changes that happened outside of TF)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedCommunity help wanted!upstream-dependencyIssue depends on changes being made to upstream dependencies (e.g. `argoproj/argo-cd`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions