Skip to content

Commit

Permalink
fix(hydrator): don't use manifest-generate-paths (argoproj#22039) (ar…
Browse files Browse the repository at this point in the history
…goproj#22015)

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Harshit-Bajpai <Harshit.Bajpai@skyscanner.net>
  • Loading branch information
crenshaw-dev authored and skyscannerBajpai committed Feb 27, 2025
1 parent e5cc307 commit 9444902
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
17 changes: 13 additions & 4 deletions controller/hydrator_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,26 @@ func (ctrl *ApplicationController) GetProcessableApps() (*appv1.ApplicationList,
return ctrl.getAppList(metav1.ListOptions{})
}

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

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

app := origApp.DeepCopy()
// Remove the manifest generate path annotation, because the feature will misbehave for apps using source hydrator.
// Setting this annotation causes GetRepoObjs to compare the dry source commit to the most recent synced commit. The
// problem is that the most recent synced commit is likely on the hydrated branch, not the dry branch. The
// comparison will throw an error and break hydration.
//
// The long-term solution will probably be to persist the synced _dry_ revision and use that for the comparison.
delete(app.Annotations, appv1.AnnotationKeyManifestGeneratePaths)

// FIXME: use cache and revision cache
objs, resp, _, err := ctrl.appStateManager.GetRepoObjs(app, sources, appLabelKey, revisions, true, true, false, project, false, false)
objs, resp, _, err := ctrl.appStateManager.GetRepoObjs(app, drySources, appLabelKey, dryRevisions, true, true, false, project, false, false)
if err != nil {
return nil, nil, fmt.Errorf("failed to get repo objects: %w", err)
}
Expand Down
11 changes: 11 additions & 0 deletions docs/user-guide/source-hydrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ hydrator will not be able to use a project-scoped push secret and will require a
Credential templates allow a single credential to be used for multiple repositories. The source hydrator does not
currently support credential templates. You will need a separate credential for each repository.

### `manifest-generate-paths` Annotation Support

The source hydrator does not currently support the [manifest-generate-paths annotation](../operator-manual/high_availability.md#manifest-paths-annotation)
for work avoidance on hydration of dry commits. In other words, the source hydrator is not able to skip hydration of dry
commits that have not changed relevant files.

The application controller _does_ honor the `manifest-generate-paths` annotation when syncing the hydrated manifests.
So if your application hydrates to the `foo` directory, and the `manifest-generate-paths` annotation is set to `foo`,
then the application controller will not re-hydrate the manifests after a commit that only affects files in the `bar`
directory.

## Prerequisites

### Handle Secrets on the Destination Cluster
Expand Down

0 comments on commit 9444902

Please sign in to comment.