Skip to content

Commit 35174dc

Browse files
gcp-cherry-pick-bot[bot]crenshaw-dev
andauthoredJan 21, 2025··
fix(hydrator): UI nil checks (cherry-pick #21598) (#21601)
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed
 

‎controller/hydrator/hydrator.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ func (h *Hydrator) ProcessHydrationQueueItem(hydrationKey HydrationQueueKey) (pr
125125
app.Status.SourceHydrator.CurrentOperation.Phase = appv1.HydrateOperationPhaseFailed
126126
failedAt := metav1.Now()
127127
app.Status.SourceHydrator.CurrentOperation.FinishedAt = &failedAt
128-
app.Status.SourceHydrator.CurrentOperation.Message = fmt.Sprintf("Failed to hydrated revision %s: %v", drySHA, err.Error())
128+
app.Status.SourceHydrator.CurrentOperation.Message = fmt.Sprintf("Failed to hydrate revision %q: %v", drySHA, err.Error())
129+
// We may or may not have gotten far enough in the hydration process to get a non-empty SHA, but set it just
130+
// in case we did.
131+
app.Status.SourceHydrator.CurrentOperation.DrySHA = drySHA
129132
h.dependencies.PersistAppHydratorStatus(origApp, &app.Status.SourceHydrator)
130133
logCtx = logCtx.WithField("app", app.QualifiedName())
131134
logCtx.Errorf("Failed to hydrate app: %v", err)
@@ -164,7 +167,7 @@ func (h *Hydrator) hydrateAppsLatestCommit(logCtx *log.Entry, hydrationKey Hydra
164167
return nil, "", "", fmt.Errorf("failed to get relevant apps for hydration: %w", err)
165168
}
166169

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

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

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

311316
closer, commitService, err := h.commitClientset.NewCommitServerClient()
312317
if err != nil {
313-
return "", "", fmt.Errorf("failed to create commit service: %w", err)
318+
return targetRevision, "", fmt.Errorf("failed to create commit service: %w", err)
314319
}
315320
defer argoio.Close(closer)
316321
resp, err := commitService.CommitHydratedManifests(context.Background(), &manifestsRequest)
317322
if err != nil {
318-
return "", "", fmt.Errorf("failed to commit hydrated manifests: %w", err)
323+
return targetRevision, "", fmt.Errorf("failed to commit hydrated manifests: %w", err)
319324
}
320325
return targetRevision, resp.HydratedSha, nil
321326
}

‎ui/src/app/applications/components/utils.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,8 @@ export function hydrationStatusMessage(app: appModels.Application) {
831831
return (
832832
<span>
833833
from{' '}
834-
<Revision repoUrl={drySource.repoURL} revision={dryCommit}>
835-
{drySource.targetRevision + ' (' + dryCommit.substr(0, 7) + ')'}
834+
<Revision repoUrl={drySource.repoURL} revision={drySource.targetRevision}>
835+
{drySource.targetRevision}
836836
</Revision>
837837
<br />
838838
to{' '}
@@ -845,8 +845,9 @@ export function hydrationStatusMessage(app: appModels.Application) {
845845
return (
846846
<span>
847847
from{' '}
848-
<Revision repoUrl={drySource.repoURL} revision={dryCommit}>
849-
{drySource.targetRevision + ' (' + dryCommit.substr(0, 7) + ')'}
848+
<Revision repoUrl={drySource.repoURL} revision={dryCommit || drySource.targetRevision}>
849+
{drySource.targetRevision}
850+
{dryCommit && ' (' + dryCommit.substr(0, 7) + ')'}
850851
</Revision>
851852
<br />
852853
to{' '}

0 commit comments

Comments
 (0)
Please sign in to comment.