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(argocd_cluster): use cluster list api to avoid 403 issues with cluster get api at cluster read time #399

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

w4rgrum
Copy link

@w4rgrum w4rgrum commented Jun 12, 2024

This PR fixes #266

Coded it with below comment in mind, meaning it is backward compatible: #266 (comment)

  • code does a Get as usual first (legacy code)
  • if it fails with a PermissionDenied error (i.e. 403) the fix is triggered (in a backward compatible way for servers <v2.8, see below)
    In that case a call is issued to the List api, reusing some code used for create cluster existence checks (that already uses this List api). Noe that this code is able to filter the cluster in the resulting list if not yet done by the ArgoCD server (servers filtering on List api does not work if <v2.8, see comments in linked issue and/or in the code ccomments)

Also added a non-regression test to validate a server-side deletion of the cluster triggers the fix.

@w4rgrum w4rgrum force-pushed the fix/argocd_cluster/issue-266-use-list-api-to-read branch 5 times, most recently from d2ffd2a to d5d059c Compare June 13, 2024 14:01
…uster get api at cluster read time

Signed-off-by: Hugo HARS <54102154+w4rgrum@users.noreply.github.com>
@w4rgrum w4rgrum force-pushed the fix/argocd_cluster/issue-266-use-list-api-to-read branch from d5d059c to ca58239 Compare June 13, 2024 14:11
@w4rgrum
Copy link
Author

w4rgrum commented Jun 13, 2024

@onematchfox PR is ready to be reviewed :)

@morhekil
Copy link

any chance to have this released as new version of the provider? This seems to be a blocker when using the provider with recent ArgoCD versions

Copy link

github-actions bot commented Jul 9, 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 Jul 9, 2024
@onematchfox
Copy link
Collaborator

...

@github-actions github-actions bot removed the Stale label Jul 10, 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 Jul 25, 2024
@onematchfox
Copy link
Collaborator

...

@github-actions github-actions bot removed the Stale label Jul 27, 2024
@onematchfox onematchfox self-requested a review August 8, 2024 13:15
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 Aug 23, 2024
@onematchfox
Copy link
Collaborator

...

@github-actions github-actions bot removed the Stale label Aug 25, 2024
Copy link

github-actions bot commented Sep 8, 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 Sep 8, 2024
@onematchfox
Copy link
Collaborator

...

@github-actions github-actions bot removed the Stale label Sep 9, 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 Sep 23, 2024
@onematchfox
Copy link
Collaborator

.

@github-actions github-actions bot removed the Stale label Oct 1, 2024
@mkilchhofer mkilchhofer changed the base branch from master to main October 1, 2024 18:07
@mkilchhofer mkilchhofer added the on-hold Issues or Pull Requests with this label will never be considered stale label Oct 15, 2024
@@ -53,6 +56,7 @@ func resourceArgoCDClusterCreate(ctx context.Context, d *schema.ResourceData, me
return errorToDiagnostics(fmt.Sprintf("failed to list existing clusters when creating cluster %s", cluster.Server), err)
}

// Here we will filter ourselves on the list so that we are backward compatible for argo-cd server with version < v2.8.0 (see coment above)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need backward compat to versions below 2.8? That is outside of our promise, no?

Copy link
Collaborator

@the-technat the-technat Oct 20, 2024

Choose a reason for hiding this comment

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

As mentioned In my review I don't think we need that compat, but since it's already coded in a way that doesn't harm we should leave it as is so far.

Copy link
Collaborator

@the-technat the-technat left a comment

Choose a reason for hiding this comment

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

LGTM, I like the way it was implemented for backwards-compatibility, although I don't think we need to implement backwards-compatibility to unsupported Argo CD versions in other places, it's already there so we should give it a go ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-hold Issues or Pull Requests with this label will never be considered stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArgoCD clusters should list to find the cluster instead of get and check for NotFound
5 participants