Skip to content

Conversation

@Rizwana777
Copy link
Contributor

What does this PR do / why we need it:
Application was not recreating when deleted from managed mode even though Principal is not in deletion state, In this fix application is recreating immediately once it is deleted from managed mode

Which issue(s) this PR fixes:

Fixes #?
https://issues.redhat.com/browse/GITOPS-7836

How to test changes / Special notes to the reviewer:

Checklist

  • Documentation update is required by this PR (and has been updated) OR no documentation update is required.

@Rizwana777 Rizwana777 changed the title Recreate application in managed mode upon deletion from spoke feat: Recreate application in managed mode upon deletion from spoke Oct 9, 2025
@Rizwana777 Rizwana777 changed the title feat: Recreate application in managed mode upon deletion from spoke feat: recreate application in managed mode upon deletion from spoke Oct 9, 2025
@Rizwana777 Rizwana777 changed the title feat: recreate application in managed mode upon deletion from spoke fix: recreate application in managed mode upon deletion from spoke Oct 9, 2025
@Rizwana777 Rizwana777 force-pushed the issue-7836-bug branch 2 times, most recently from 2c71774 to 0c49341 Compare October 9, 2025 12:54
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.48%. Comparing base (591bcce) to head (59188ab).

Files with missing lines Patch % Lines
agent/outbound.go 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #605      +/-   ##
==========================================
+ Coverage   45.41%   45.48%   +0.07%     
==========================================
  Files          90       90              
  Lines        9907     9915       +8     
==========================================
+ Hits         4499     4510      +11     
+ Misses       4949     4944       -5     
- Partials      459      461       +2     

☔ 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.

@chetan-rns
Copy link
Collaborator

@Rizwana777 Can you please pull the latest updates from main? Hopefully, that should fix the e2e tests.

// In managed mode, if the application was deleted from the agent but the principal
// application is not in deletion state, we should recreate it by sending the
// application spec back to the managed agent
logCtx.Info("Recreating application in managed agent to maintain desired state")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We maintain a cache of the desired state app spec on the agent. Can we use that to revert the deletion?

Ref: #567

Also, some of these methods are being refactored to avoid duplication here #596

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update this logic

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Rizwana777 #596 has been merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @chetan-rns I will modify my PR accordingly

@Rizwana777 Rizwana777 requested a review from mikeshng as a code owner October 28, 2025 11:47
@Rizwana777 Rizwana777 changed the title fix: recreate application in managed mode upon deletion from spoke [WIP]fix: recreate application in managed mode upon deletion from spoke Oct 28, 2025
@Rizwana777 Rizwana777 changed the title [WIP]fix: recreate application in managed mode upon deletion from spoke fix: recreate application in managed mode upon deletion from spoke [WIP] Oct 28, 2025
@Rizwana777 Rizwana777 changed the title fix: recreate application in managed mode upon deletion from spoke [WIP] fix: recreate application in managed mode upon deletion from spoke Oct 29, 2025

t.Log("Verify application is deleted from managed agent")
requires.Eventually(func() bool {
app := argoapp.Application{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check may not always pass. What if the app gets recreated before we reach this check?

// 1. A managed application exists on both principal and managed agent
// 2. The application is directly deleted from the managed agent (while agent is running)
// 3. The agent should detect this unauthorized deletion and recreate the application automatically
func (suite *ResyncTestSuite) Test_ManagedAppRecreationOnDirectDeletion() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move this test to appcache_test.go? We have all the revert-based tests in that file. For example, here's a similar test for the autonomous agent https://github.com/argoproj-labs/argocd-agent/blob/main/test/e2e/appcache_test.go#L235

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.

3 participants