Skip to content

refactor: break up appHealthOrSyncStatusChanged into shared predicates #6035

@EronWright

Description

@EronWright

Context

#5995 introduced appHealthOrSyncStatusChanged() in
pkg/controller/stages/event_handlers.go — a monolithic function that
detects four distinct signals and gates the Stage reconciler's Application
watch:

  1. Health status change
  2. Operation phase change (any transition)
  3. Sync revision change
  4. reconciledAt crossing finishedAt (health becomes trustworthy after a hard refresh)

#5832 added typed predicates for the Promotions controller's Application watch:
ArgoCDAppOperationCompleted, ArgoCDAppHealthChanged, ArgoCDAppSyncChanged,
and ArgoCDAppReconciledAfterOperation. Signals 1, 2, and 4 are identical in
both controllers; only signal 3 (sync revision) is Stages-specific.

Proposed refactor

Break appHealthOrSyncStatusChanged() into three exported typed predicates
(parallel to those in pkg/controller/promotions/predicates.go) that can be
shared:

  • ArgoCDAppHealthChanged — signal 1
  • ArgoCDAppOperationPhaseChanged — signal 2 (any phase change, not just to-completed)
  • ArgoCDAppReconciledAfterOperation — signal 4

Move them to a shared location (e.g. pkg/controller/argocd/predicates.go)
and use them in both the Stages and Promotions watches, replacing the current
inline implementations in each.

Signal 3 (sync revision) remains Stages-only and stays in
event_handlers.go.

Reference

Metadata

Metadata

Assignees

Labels

area/controllerAffects the (main) controllerkind/refactorNon-functional changes to implementation detailspriority/normalThis is the priority for most work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions