feat: implement sync operation termination support #595
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do / why we need it:
This PR implements sync operation termination support for ArgoCD Agent, allowing users to abort running sync operations that were previously unstoppable.
Problem
Currently, when users trigger sync operations on Applications in ArgoCD Agent, there was no way to abort them once started. This is because the
.status.operationState.phase
field (which indicates "Terminating" state) was not propagated from the Principal to the Agents.Solution:
OperationTerminate
event type for signaling sync abort requests.status.operationState.phase
changes to "Terminating" and sends this event to the targeted AgentKey Changes:
OperationTerminate
event type ininternal/event/event.go
principal/callbacks.go
to detect terminating state changes and send eventsOperationTerminate
event processing inprincipal/event.go
agent/inbound.go
Which issue(s) this PR fixes:
Fixes #565
How to test changes / Special notes to the reviewer:
Testing Approach
Due to TLS certificate complexity in the full environment, we implemented comprehensive unit tests to validate the core logic:
Unit Tests Added:
Principal Callback Tests (
principal/callbacks_operation_terminate_test.go
):shouldSendOperationTerminateEvent
function logicPrincipal Event Processing Tests (
principal/event_operation_terminate_test.go
):Agent Inbound Tests (
agent/inbound_operation_terminate_test.go
):Integration Tests (
test_sync_termination_integration_test.go
):Checklist