Skip to content

Commit 2dd70de

Browse files
fix(hydrator): don't use manifest-generate-paths (#22039) (cherry-pick #22015) (#22061)
Signed-off-by: Michael Crenshaw <[email protected]> Co-authored-by: Michael Crenshaw <[email protected]>
1 parent d79185a commit 2dd70de

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

controller/hydrator_dependencies.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,26 @@ func (ctrl *ApplicationController) GetProcessableApps() (*appv1.ApplicationList,
3030
return ctrl.getAppList(metav1.ListOptions{})
3131
}
3232

33-
func (ctrl *ApplicationController) GetRepoObjs(app *appv1.Application, source appv1.ApplicationSource, revision string, project *appv1.AppProject) ([]*unstructured.Unstructured, *apiclient.ManifestResponse, error) {
34-
sources := []appv1.ApplicationSource{source}
35-
revisions := []string{revision}
33+
func (ctrl *ApplicationController) GetRepoObjs(origApp *appv1.Application, drySource appv1.ApplicationSource, revision string, project *appv1.AppProject) ([]*unstructured.Unstructured, *apiclient.ManifestResponse, error) {
34+
drySources := []appv1.ApplicationSource{drySource}
35+
dryRevisions := []string{revision}
3636

3737
appLabelKey, err := ctrl.settingsMgr.GetAppInstanceLabelKey()
3838
if err != nil {
3939
return nil, nil, fmt.Errorf("failed to get app instance label key: %w", err)
4040
}
4141

42+
app := origApp.DeepCopy()
43+
// Remove the manifest generate path annotation, because the feature will misbehave for apps using source hydrator.
44+
// Setting this annotation causes GetRepoObjs to compare the dry source commit to the most recent synced commit. The
45+
// problem is that the most recent synced commit is likely on the hydrated branch, not the dry branch. The
46+
// comparison will throw an error and break hydration.
47+
//
48+
// The long-term solution will probably be to persist the synced _dry_ revision and use that for the comparison.
49+
delete(app.Annotations, appv1.AnnotationKeyManifestGeneratePaths)
50+
4251
// FIXME: use cache and revision cache
43-
objs, resp, _, err := ctrl.appStateManager.GetRepoObjs(app, sources, appLabelKey, revisions, true, true, false, project, false, false)
52+
objs, resp, _, err := ctrl.appStateManager.GetRepoObjs(app, drySources, appLabelKey, dryRevisions, true, true, false, project, false, false)
4453
if err != nil {
4554
return nil, nil, fmt.Errorf("failed to get repo objects: %w", err)
4655
}

docs/user-guide/source-hydrator.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ hydrator will not be able to use a project-scoped push secret and will require a
166166
Credential templates allow a single credential to be used for multiple repositories. The source hydrator does not
167167
currently support credential templates. You will need a separate credential for each repository.
168168

169+
### `manifest-generate-paths` Annotation Support
170+
171+
The source hydrator does not currently support the [manifest-generate-paths annotation](../operator-manual/high_availability.md#manifest-paths-annotation)
172+
for work avoidance on hydration of dry commits. In other words, the source hydrator is not able to skip hydration of dry
173+
commits that have not changed relevant files.
174+
175+
The application controller _does_ honor the `manifest-generate-paths` annotation when syncing the hydrated manifests.
176+
So if your application hydrates to the `foo` directory, and the `manifest-generate-paths` annotation is set to `foo`,
177+
then the application controller will not re-hydrate the manifests after a commit that only affects files in the `bar`
178+
directory.
179+
169180
## Prerequisites
170181

171182
### Handle Secrets on the Destination Cluster

0 commit comments

Comments
 (0)