Skip to content

Commit

Permalink
fix(hydrator): UI nil checks (argoproj#21598)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crenshaw <[email protected]>
  • Loading branch information
crenshaw-dev authored Jan 21, 2025
1 parent ed3cc48 commit 9429275
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
13 changes: 9 additions & 4 deletions controller/hydrator/hydrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ func (h *Hydrator) ProcessHydrationQueueItem(hydrationKey HydrationQueueKey) (pr
app.Status.SourceHydrator.CurrentOperation.Phase = appv1.HydrateOperationPhaseFailed
failedAt := metav1.Now()
app.Status.SourceHydrator.CurrentOperation.FinishedAt = &failedAt
app.Status.SourceHydrator.CurrentOperation.Message = fmt.Sprintf("Failed to hydrated revision %s: %v", drySHA, err.Error())
app.Status.SourceHydrator.CurrentOperation.Message = fmt.Sprintf("Failed to hydrate revision %q: %v", drySHA, err.Error())
// We may or may not have gotten far enough in the hydration process to get a non-empty SHA, but set it just
// in case we did.
app.Status.SourceHydrator.CurrentOperation.DrySHA = drySHA
h.dependencies.PersistAppHydratorStatus(origApp, &app.Status.SourceHydrator)
logCtx = logCtx.WithField("app", app.QualifiedName())
logCtx.Errorf("Failed to hydrate app: %v", err)
Expand Down Expand Up @@ -164,7 +167,7 @@ func (h *Hydrator) hydrateAppsLatestCommit(logCtx *log.Entry, hydrationKey Hydra
return nil, "", "", fmt.Errorf("failed to get relevant apps for hydration: %w", err)
}

hydratedRevision, dryRevision, err := h.hydrate(logCtx, relevantApps)
dryRevision, hydratedRevision, err := h.hydrate(logCtx, relevantApps)
if err != nil {
return relevantApps, dryRevision, "", fmt.Errorf("failed to hydrate apps: %w", err)
}
Expand Down Expand Up @@ -259,6 +262,8 @@ func (h *Hydrator) hydrate(logCtx *log.Entry, apps []*appv1.Application) (string
return "", "", fmt.Errorf("failed to get repo objects: %w", err)
}

// This should be the DRY SHA. We set it here so that after processing the first app, all apps are hydrated
// using the same SHA.
targetRevision = resp.Revision

// Set up a ManifestsRequest
Expand Down Expand Up @@ -310,12 +315,12 @@ func (h *Hydrator) hydrate(logCtx *log.Entry, apps []*appv1.Application) (string

closer, commitService, err := h.commitClientset.NewCommitServerClient()
if err != nil {
return "", "", fmt.Errorf("failed to create commit service: %w", err)
return targetRevision, "", fmt.Errorf("failed to create commit service: %w", err)
}
defer argoio.Close(closer)
resp, err := commitService.CommitHydratedManifests(context.Background(), &manifestsRequest)
if err != nil {
return "", "", fmt.Errorf("failed to commit hydrated manifests: %w", err)
return targetRevision, "", fmt.Errorf("failed to commit hydrated manifests: %w", err)
}
return targetRevision, resp.HydratedSha, nil
}
Expand Down
9 changes: 5 additions & 4 deletions ui/src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,8 @@ export function hydrationStatusMessage(app: appModels.Application) {
return (
<span>
from{' '}
<Revision repoUrl={drySource.repoURL} revision={dryCommit}>
{drySource.targetRevision + ' (' + dryCommit.substr(0, 7) + ')'}
<Revision repoUrl={drySource.repoURL} revision={drySource.targetRevision}>
{drySource.targetRevision}
</Revision>
<br />
to{' '}
Expand All @@ -845,8 +845,9 @@ export function hydrationStatusMessage(app: appModels.Application) {
return (
<span>
from{' '}
<Revision repoUrl={drySource.repoURL} revision={dryCommit}>
{drySource.targetRevision + ' (' + dryCommit.substr(0, 7) + ')'}
<Revision repoUrl={drySource.repoURL} revision={dryCommit || drySource.targetRevision}>
{drySource.targetRevision}
{dryCommit && ' (' + dryCommit.substr(0, 7) + ')'}
</Revision>
<br />
to{' '}
Expand Down

0 comments on commit 9429275

Please sign in to comment.