-
Notifications
You must be signed in to change notification settings - Fork 6.6k
fix(hydrator): use refresh paths from drySource when source hydration is enabled #25516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
e741ee0
b1d4286
c362704
3d6dc06
33e365c
0eade53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,8 +108,15 @@ func GetAppRefreshPaths(app *v1alpha1.Application) []string { | |
| if filepath.IsAbs(item) { | ||
| paths = append(paths, item[1:]) | ||
| } else { | ||
| for _, source := range app.Spec.GetSources() { | ||
| paths = append(paths, filepath.Clean(filepath.Join(source.Path, item))) | ||
| // For sourceHydrator apps, resolve paths relative to DRY source | ||
| if app.Spec.SourceHydrator != nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should receive the current source in parameter since it influence the refresh path.
|
||
| drySource := app.Spec.SourceHydrator.GetDrySource() | ||
| paths = append(paths, filepath.Clean(filepath.Join(drySource.Path, item))) | ||
| } else { | ||
| // For non-hydrator apps, use the regular source(s) | ||
| for _, source := range app.Spec.GetSources() { | ||
| paths = append(paths, filepath.Clean(filepath.Join(source.Path, item))) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| { | ||
| "ref": "refs/heads/environments/dev", | ||
| "before": "d5c1ffa8e294bc18c639bfb4e0df499251034414", | ||
| "after": "63738bb582c8b540af7bcfc18f87c575c3ed66e0", | ||
| "created": false, | ||
| "deleted": false, | ||
| "forced": true, | ||
| "base_ref": null, | ||
| "compare": "https://github.com/jessesuen/test-repo/compare/d5c1ffa8e294...63738bb582c8", | ||
| "commits": [ | ||
| { | ||
| "id": "63738bb582c8b540af7bcfc18f87c575c3ed66e0", | ||
| "tree_id": "64897da445207e409ad05af93b1f349ad0a4ee19", | ||
| "distinct": true, | ||
| "message": "Update hydrated manifests", | ||
| "timestamp": "2018-05-04T15:40:02-07:00", | ||
| "url": "https://github.com/jessesuen/test-repo/commit/63738bb582c8b540af7bcfc18f87c575c3ed66e0", | ||
| "author": { | ||
| "name": "Jesse Suen", | ||
| "email": "[email protected]", | ||
| "username": "jessesuen" | ||
| }, | ||
| "committer": { | ||
| "name": "Jesse Suen", | ||
| "email": "[email protected]", | ||
| "username": "jessesuen" | ||
| }, | ||
| "added": [ | ||
| "ksapps/test-app/environments/staging-argocd-demo/main.jsonnet", | ||
| "ksapps/test-app/environments/staging-argocd-demo/params.libsonnet" | ||
| ], | ||
| "removed": [ | ||
|
|
||
| ], | ||
| "modified": [ | ||
| "ksapps/test-app/app.yaml" | ||
| ] | ||
| } | ||
| ], | ||
| "head_commit": { | ||
| "id": "63738bb582c8b540af7bcfc18f87c575c3ed66e0", | ||
| "tree_id": "64897da445207e409ad05af93b1f349ad0a4ee19", | ||
| "distinct": true, | ||
| "message": "Add staging-argocd-demo environment", | ||
| "timestamp": "2018-05-04T15:40:02-07:00", | ||
| "url": "https://github.com/jessesuen/test-repo/commit/63738bb582c8b540af7bcfc18f87c575c3ed66e0", | ||
| "author": { | ||
| "name": "Jesse Suen", | ||
| "email": "[email protected]", | ||
| "username": "jessesuen" | ||
| }, | ||
| "committer": { | ||
| "name": "Jesse Suen", | ||
| "email": "[email protected]", | ||
| "username": "jessesuen" | ||
| }, | ||
| "added": [ | ||
| "ksapps/test-app/environments/staging-argocd-demo/main.jsonnet", | ||
| "ksapps/test-app/environments/staging-argocd-demo/params.libsonnet" | ||
| ], | ||
| "removed": [ | ||
|
|
||
| ], | ||
| "modified": [ | ||
| "ksapps/test-app/app.yaml" | ||
| ] | ||
| }, | ||
| "repository": { | ||
| "id": 123060978, | ||
| "name": "test-repo", | ||
| "full_name": "jessesuen/test-repo", | ||
| "owner": { | ||
| "name": "jessesuen", | ||
| "email": "[email protected]", | ||
| "login": "jessesuen", | ||
| "id": 12677113, | ||
| "avatar_url": "https://avatars0.githubusercontent.com/u/12677113?v=4", | ||
| "gravatar_id": "", | ||
| "url": "https://api.github.com/users/jessesuen", | ||
| "html_url": "https://github.com/jessesuen", | ||
| "followers_url": "https://api.github.com/users/jessesuen/followers", | ||
| "following_url": "https://api.github.com/users/jessesuen/following{/other_user}", | ||
| "gists_url": "https://api.github.com/users/jessesuen/gists{/gist_id}", | ||
| "starred_url": "https://api.github.com/users/jessesuen/starred{/owner}{/repo}", | ||
| "subscriptions_url": "https://api.github.com/users/jessesuen/subscriptions", | ||
| "organizations_url": "https://api.github.com/users/jessesuen/orgs", | ||
| "repos_url": "https://api.github.com/users/jessesuen/repos", | ||
| "events_url": "https://api.github.com/users/jessesuen/events{/privacy}", | ||
| "received_events_url": "https://api.github.com/users/jessesuen/received_events", | ||
| "type": "User", | ||
| "site_admin": false | ||
| }, | ||
| "private": false, | ||
| "html_url": "https://github.com/jessesuen/test-repo", | ||
| "description": "Test Repository", | ||
| "fork": false, | ||
| "url": "https://github.com/jessesuen/test-repo", | ||
| "forks_url": "https://api.github.com/repos/jessesuen/test-repo/forks", | ||
| "keys_url": "https://api.github.com/repos/jessesuen/test-repo/keys{/key_id}", | ||
| "collaborators_url": "https://api.github.com/repos/jessesuen/test-repo/collaborators{/collaborator}", | ||
| "teams_url": "https://api.github.com/repos/jessesuen/test-repo/teams", | ||
| "hooks_url": "https://api.github.com/repos/jessesuen/test-repo/hooks", | ||
| "issue_events_url": "https://api.github.com/repos/jessesuen/test-repo/issues/events{/number}", | ||
| "events_url": "https://api.github.com/repos/jessesuen/test-repo/events", | ||
| "assignees_url": "https://api.github.com/repos/jessesuen/test-repo/assignees{/user}", | ||
| "branches_url": "https://api.github.com/repos/jessesuen/test-repo/branches{/branch}", | ||
| "tags_url": "https://api.github.com/repos/jessesuen/test-repo/tags", | ||
| "blobs_url": "https://api.github.com/repos/jessesuen/test-repo/git/blobs{/sha}", | ||
| "git_tags_url": "https://api.github.com/repos/jessesuen/test-repo/git/tags{/sha}", | ||
| "git_refs_url": "https://api.github.com/repos/jessesuen/test-repo/git/refs{/sha}", | ||
| "trees_url": "https://api.github.com/repos/jessesuen/test-repo/git/trees{/sha}", | ||
| "statuses_url": "https://api.github.com/repos/jessesuen/test-repo/statuses/{sha}", | ||
| "languages_url": "https://api.github.com/repos/jessesuen/test-repo/languages", | ||
| "stargazers_url": "https://api.github.com/repos/jessesuen/test-repo/stargazers", | ||
| "contributors_url": "https://api.github.com/repos/jessesuen/test-repo/contributors", | ||
| "subscribers_url": "https://api.github.com/repos/jessesuen/test-repo/subscribers", | ||
| "subscription_url": "https://api.github.com/repos/jessesuen/test-repo/subscription", | ||
| "commits_url": "https://api.github.com/repos/jessesuen/test-repo/commits{/sha}", | ||
| "git_commits_url": "https://api.github.com/repos/jessesuen/test-repo/git/commits{/sha}", | ||
| "comments_url": "https://api.github.com/repos/jessesuen/test-repo/comments{/number}", | ||
| "issue_comment_url": "https://api.github.com/repos/jessesuen/test-repo/issues/comments{/number}", | ||
| "contents_url": "https://api.github.com/repos/jessesuen/test-repo/contents/{+path}", | ||
| "compare_url": "https://api.github.com/repos/jessesuen/test-repo/compare/{base}...{head}", | ||
| "merges_url": "https://api.github.com/repos/jessesuen/test-repo/merges", | ||
| "archive_url": "https://api.github.com/repos/jessesuen/test-repo/{archive_format}{/ref}", | ||
| "downloads_url": "https://api.github.com/repos/jessesuen/test-repo/downloads", | ||
| "issues_url": "https://api.github.com/repos/jessesuen/test-repo/issues{/number}", | ||
| "pulls_url": "https://api.github.com/repos/jessesuen/test-repo/pulls{/number}", | ||
| "milestones_url": "https://api.github.com/repos/jessesuen/test-repo/milestones{/number}", | ||
| "notifications_url": "https://api.github.com/repos/jessesuen/test-repo/notifications{?since,all,participating}", | ||
| "labels_url": "https://api.github.com/repos/jessesuen/test-repo/labels{/name}", | ||
| "releases_url": "https://api.github.com/repos/jessesuen/test-repo/releases{/id}", | ||
| "deployments_url": "https://api.github.com/repos/jessesuen/test-repo/deployments", | ||
| "created_at": 1519698615, | ||
| "updated_at": "2018-05-04T22:37:55Z", | ||
| "pushed_at": 1525473610, | ||
| "git_url": "git://github.com/jessesuen/test-repo.git", | ||
| "ssh_url": "[email protected]:jessesuen/test-repo.git", | ||
| "clone_url": "https://github.com/jessesuen/test-repo.git", | ||
| "svn_url": "https://github.com/jessesuen/test-repo", | ||
| "homepage": null, | ||
| "size": 538, | ||
| "stargazers_count": 0, | ||
| "watchers_count": 0, | ||
| "language": null, | ||
| "has_issues": true, | ||
| "has_projects": true, | ||
| "has_downloads": true, | ||
| "has_wiki": true, | ||
| "has_pages": false, | ||
| "forks_count": 1, | ||
| "mirror_url": null, | ||
| "archived": false, | ||
| "open_issues_count": 0, | ||
| "license": null, | ||
| "forks": 1, | ||
| "open_issues": 0, | ||
| "watchers": 0, | ||
| "default_branch": "master", | ||
| "stargazers": 0, | ||
| "master_branch": "master" | ||
| }, | ||
| "pusher": { | ||
| "name": "jessesuen", | ||
| "email": "[email protected]" | ||
| }, | ||
| "sender": { | ||
| "login": "jessesuen", | ||
| "id": 12677113, | ||
| "avatar_url": "https://avatars0.githubusercontent.com/u/12677113?v=4", | ||
| "gravatar_id": "", | ||
| "url": "https://api.github.com/users/jessesuen", | ||
| "html_url": "https://github.com/jessesuen", | ||
| "followers_url": "https://api.github.com/users/jessesuen/followers", | ||
| "following_url": "https://api.github.com/users/jessesuen/following{/other_user}", | ||
| "gists_url": "https://api.github.com/users/jessesuen/gists{/gist_id}", | ||
| "starred_url": "https://api.github.com/users/jessesuen/starred{/owner}{/repo}", | ||
| "subscriptions_url": "https://api.github.com/users/jessesuen/subscriptions", | ||
| "organizations_url": "https://api.github.com/users/jessesuen/orgs", | ||
| "repos_url": "https://api.github.com/users/jessesuen/repos", | ||
| "events_url": "https://api.github.com/users/jessesuen/events{/privacy}", | ||
| "received_events_url": "https://api.github.com/users/jessesuen/received_events", | ||
| "type": "User", | ||
| "site_admin": false | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,7 +368,8 @@ func (a *ArgoCDWebhookHandler) HandleEvent(payload any) { | |
| for _, app := range filteredApps { | ||
| if app.Spec.SourceHydrator != nil { | ||
| drySource := app.Spec.SourceHydrator.GetDrySource() | ||
| if sourceRevisionHasChanged(drySource, revision, touchedHead) && sourceUsesURL(drySource, webURL, repoRegexp) { | ||
| syncSource := app.Spec.SourceHydrator.GetSyncSource() | ||
| if sourceRevisionHasChanged(drySource, revision, touchedHead) && sourceUsesURL(drySource, webURL, repoRegexp) { // handle webhook for drySource | ||
| refreshPaths := path.GetAppRefreshPaths(&app) | ||
| if path.AppFilesHaveChanged(refreshPaths, changedFiles) { | ||
| namespacedAppInterface := a.appClientset.ArgoprojV1alpha1().Applications(app.Namespace) | ||
|
|
@@ -379,6 +380,16 @@ func (a *ArgoCDWebhookHandler) HandleEvent(payload any) { | |
| continue | ||
| } | ||
| } | ||
| } else if sourceRevisionHasChanged(syncSource, revision, touchedHead) && sourceUsesURL(syncSource, webURL, repoRegexp) { // handle webhook for syncSource | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should call |
||
| // syncSource webhook events only trigger sync, not hydration. Unlike drySource events, | ||
| // skip the manifest_generate_path file check since hydration is not required here. | ||
| namespacedAppInterface := a.appClientset.ArgoprojV1alpha1().Applications(app.Namespace) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also check if |
||
| 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 | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is also called in the GetRepoObjs function and should return the right value depending if we are current acting on the dry or sync source.