Skip to content

Conversation

jgwest
Copy link
Member

@jgwest jgwest commented Jul 18, 2025

What does this PR do / why we need it:

  • At present, if you perform a cascade delete on an Argo CD Application from principal, the child resources of that Application will not be deleted on managed-agent.
  • This is due to the following, which have been rectified:
    • The Argo CD Application deletion .metadata.finalizer was being removed by principal
    • Deletion events for managed-agent were not being sent by agent
    • Deletion events for managed-agent were not being processed by principal
  • Plus updated unit/E2E tests

Which issue(s) this PR fixes:

Fixes #443

@jgwest jgwest force-pushed the fix-cascade-delete-july-2025 branch from 263f436 to 832c241 Compare July 18, 2025 11:02
return err
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Not strictly related to the PR, but this makes the deletion function slightly more robust by removing finalizers if we're not able to delete within 60 seconds.

@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2025

Codecov Report

Attention: Patch coverage is 25.49020% with 38 lines in your changes missing coverage. Please review.

Project coverage is 44.47%. Comparing base (759f0d9) to head (e2cb339).

Files with missing lines Patch % Lines
principal/event.go 29.72% 22 Missing and 4 partials ⚠️
internal/manager/application/application.go 14.28% 10 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #462      +/-   ##
==========================================
- Coverage   44.49%   44.47%   -0.02%     
==========================================
  Files          86       86              
  Lines       10463    10495      +32     
==========================================
+ Hits         4655     4668      +13     
- Misses       5431     5444      +13     
- Partials      377      383       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jgwest jgwest force-pushed the fix-cascade-delete-july-2025 branch from 2357556 to e22fef7 Compare July 18, 2025 12:04
jgwest added 2 commits July 22, 2025 11:47
… app resources

Signed-off-by: Jonathan West <jonwest@redhat.com>
Signed-off-by: Jonathan West <jonwest@redhat.com>
@jgwest jgwest force-pushed the fix-cascade-delete-july-2025 branch from bab5c2e to e2cb339 Compare July 22, 2025 15:52
if deletionTimestampChanged {
logCtx.Infof("deletionTimestamp of managed agent changed from nil to non-nil, so deleting Application")
if err := m.applicationBackend.Delete(ctx, incoming.Name, incoming.Namespace, ptr.To(backend.DeletePropagationForeground)); err != nil {
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason why we should delete the resource again if the incoming resource already has a deletion timestamp set? If we remove the finalizer, it should be deleted automatically.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to put the managed-agent Application into deletion state, so that Argo CD/K8s starts the process of (cascade) deleting the child resources of the Application.

Once the child resources are deleted, the finalizer is removed.

The deletionTimestamp field is immutable, so in order to add it to a resource you need to call the K8s Delete API

Copy link
Collaborator

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

LGTM

@jannfis jannfis merged commit 128e239 into argoproj-labs:main Jul 23, 2025
16 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.

Cascading delete does not work (anymore)
4 participants