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(delete): recreate cluster when deleted via argocd-ui #118

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions pkg/controller/cluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,26 @@ func (e *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex
observedCluster, err := e.client.Get(ctx, &clusterQuery)
if err != nil {
switch {
case cluster.IsErrorClusterNotFound(err),
cluster.IsErrorPermissionDenied(err) && meta.WasDeleted(cr):
case cluster.IsErrorClusterNotFound(err):
// Case: Cluster not found
return managed.ExternalObservation{}, nil

case cluster.IsErrorPermissionDenied(err):
if meta.WasDeleted(cr) {
// Case: Cluster is deleted,
// and the managed resource has a deletion timestamp
return managed.ExternalObservation{}, nil
}
// Case: Cluster is deleted via argocd-ui,
// but the managed resource still exists
return managed.ExternalObservation{
ResourceExists: false,
}, nil

default:
// Default case: Handle other errors
return managed.ExternalObservation{}, errors.Wrap(err, errGetFailed)
}
return managed.ExternalObservation{}, errors.Wrap(err, errGetFailed)
}
if meta.WasDeleted(cr) && meta.GetExternalName(cr) != observedCluster.Name {
// ArgoCD Cluster resource ignores the name field. This detects the deletion of the default cluster resource.
Expand Down
Loading