Skip to content

Conversation

@FourFifthsCode
Copy link
Contributor

@FourFifthsCode FourFifthsCode commented Dec 4, 2025

When using argocd.argoproj.io/manifest-generate-paths annotation with source hydrator enabled apps, make sure to base relative paths off of drySource path and not the sync source.

This fix allows hydration to properly trigger refreshes on paths specified by manifest-generate-paths annotation.

Hydration with sourceHydrator:

  • syncSource refresh - Direct sync from hydrated branch without re-hydration
  • drySource with annotation - Hydration triggered only when changed files match manifest-generate-paths
  • drySource without annotation - Hydration triggered when changed files are within drySource path (default fallback)

Standard applications (no sourceHydrator):

  • With annotation - Refresh only when changed files match manifest-generate-paths
  • Without annotation - Always refresh on any change (default behavior)

Partial fix for #25094

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@FourFifthsCode FourFifthsCode requested a review from a team as a code owner December 4, 2025 15:21
@bunnyshell
Copy link

bunnyshell bot commented Dec 4, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@crenshaw-dev
Copy link
Member

I'll override DCO if it becomes a huge pain to fix. :-)

@FourFifthsCode
Copy link
Contributor Author

I'll override DCO if it becomes a huge pain to fix. :-)

I rebased on upstream and just cherry picked @pbhatnagar-oss's commits

Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

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

I think after GetAppRefreshPaths is changed to receive the source in parameters, the implementation of the webhook handle event is much simpler.

if the app has an hydrator source configured, check the DrySource for change.
then, check the default source for change.

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.65%. Comparing base (1dc85e5) to head (2038e9f).

Files with missing lines Patch % Lines
util/webhook/webhook.go 80.00% 2 Missing and 1 partial ⚠️
controller/state.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #25516      +/-   ##
==========================================
+ Coverage   62.61%   62.65%   +0.04%     
==========================================
  Files         353      353              
  Lines       50159    50181      +22     
==========================================
+ Hits        31405    31440      +35     
+ Misses      15737    15721      -16     
- Partials     3017     3020       +3     

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

Comment on lines 383 to 398
} else if sourceRevisionHasChanged(syncSource, revision, touchedHead) && sourceUsesURL(syncSource, webURL, repoRegexp) { // handle webhook for syncSource
if err := a.storePreviouslyCachedManifests(&app, change, trackingMethod, appInstanceLabelKey, installationID); err != nil {
log.Warnf("Failed to store cached manifests of previous revision for app '%s': %v", app.Name, err)
}

refreshPaths := path.GetAppRefreshPaths(&app, syncSource)
if path.AppFilesHaveChanged(refreshPaths, changedFiles) {
// syncSource changes trigger sync (no hydration needed), but still filter irrelevant files
namespacedAppInterface := a.appClientset.ArgoprojV1alpha1().Applications(app.Namespace)
log.Infof("webhook trigger refresh app from syncSource '%s'", app.Name)
_, err = argo.RefreshApp(namespacedAppInterface, app.Name, v1alpha1.RefreshTypeNormal, true)
if err != nil {
log.Warnf("Failed to refresh app '%s' after syncSource change: %v", app.Name, err)
continue
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This does not seem necessary since app.Spec.GetSources() handles the hydrator syncSource below.

}

refreshPaths := path.GetAppRefreshPaths(&app, syncSource)
if path.AppFilesHaveChanged(refreshPaths, changedFiles) {
Copy link
Member

Choose a reason for hiding this comment

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

if path.AppFilesHaveChanged is false, then it needs to do the same as the loop below to update the cache. So it needs to call storePreviouslyCachedManifests for the current source.

storePreviouslyCachedManifests will require a source to be added to its param to know on which source it is currently acting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved logic so that we only need to have code that calls RefreshApp/storePreviouslyCachedManifests once based on booleans. How does that look to you?

hook.Reset()
}

func TestGitHubCommitEvent_SyncSourceRefresh(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

The unit tests should validate that SetNewRevisionManifests has been called when the source matches, but the path do not match any changed files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like we can just check if the refresh/hydrate annotations were correctly applied since that is the result of RefreshApp function being called.

FourFifthsCode and others added 11 commits December 19, 2025 12:25
Signed-off-by: pbhatnagar-oss <[email protected]>
Signed-off-by: Codey Jenkins <[email protected]>
Add AppFilesHaveChanged check to syncSource webhook handling and fix
GetAppRefreshPaths to return source path for drySource without annotation.
This ensures consistent file filtering behavior for both dry and sync sources.

Signed-off-by: Codey Jenkins <[email protected]>
Use .Equals() instead of == when comparing source to syncSource in annotation
processing. The == comparison always failed since GetSyncSource() returns a
new struct each time.

Signed-off-by: Codey Jenkins <[email protected]>
Hydration with sourceHydrator:
syncSource refresh - Direct sync from hydrated branch without re-hydration
drySource with annotation - Hydration triggered only when changed files match manifest-generate-paths
drySource without annotation - Hydration triggered when changed files are within drySource path (default fallback)

Standard applications (no sourceHydrator):
With annotation - Refresh only when changed files match manifest-generate-paths
Without annotation - Always refresh on any change (default behavior)

Signed-off-by: Codey Jenkins <[email protected]>
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.

4 participants