Skip to content

Conversation

chetan-rns
Copy link
Collaborator

What does this PR do / why we need it:

This PR extends #400

All updates to the AppProject and the Repository must come from the source, i.e, the principal in managed mode and the agent in autonomous mode. Any changes made by the user on the non-source cluster must be reverted to keep the resources in sync with the source cluster. In this PR:

  • Use a generic cache to store spec to avoid code repetition.
  • Revert the invalid updates and deletions in the respective callbacks
  • We also use the same cache to differentiate between user-initiated deletion and the valid deletions coming from the source.
  • Include unit tests and e2e tests

Which issue(s) this PR fixes:

Fixes #546

How to test changes / Special notes to the reviewer:

  1. Update/Delete the AppProject on a non-source cluster.
  2. It must be reverted to be in sync with the source
  3. Update/Delete the Repository on the agent and observe the agent reverting the changes.

Checklist

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

@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 41.89189% with 215 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.31%. Comparing base (2f23d9f) to head (0059af7).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
agent/agent.go 10.25% 35 Missing ⚠️
internal/manager/repository/repository.go 0.00% 31 Missing ⚠️
internal/manager/appproject/appproject.go 0.00% 29 Missing ⚠️
agent/outbound.go 16.66% 19 Missing and 6 partials ⚠️
principal/server.go 50.00% 19 Missing and 6 partials ⚠️
internal/cache/resource_cache.go 67.30% 17 Missing ⚠️
agent/inbound.go 73.33% 9 Missing and 3 partials ⚠️
principal/event.go 33.33% 12 Missing ⚠️
internal/manager/application/application.go 15.38% 11 Missing ⚠️
principal/callbacks.go 16.66% 10 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #596      +/-   ##
==========================================
- Coverage   45.65%   45.31%   -0.35%     
==========================================
  Files          90       90              
  Lines       12020    12276     +256     
==========================================
+ Hits         5488     5563      +75     
- Misses       6087     6253     +166     
- Partials      445      460      +15     

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

Signed-off-by: Chetan Banavikalmutt <[email protected]>
Assisted-by: Cursor
Signed-off-by: Chetan Banavikalmutt <[email protected]>
Signed-off-by: Chetan Banavikalmutt <[email protected]>
Assisted-by: Cursor
@chetan-rns chetan-rns force-pushed the revert-appproject-changes branch from 8960f96 to 11b52c3 Compare October 8, 2025 15:07
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.

Direct updates on AppProject and Repository must be reverted by the agent
2 participants