From ae5a92ab9ee94317df3be5a6762b7117b0d42805 Mon Sep 17 00:00:00 2001 From: Ryan Currah Date: Tue, 23 Apr 2024 14:58:15 -0400 Subject: [PATCH 1/2] fix(ui): try retrieving live workflow first then archived Retrieving an archived workflow is the fallback now. Curently an error appears when loading a workflow because archived workflows are not enabled and the ui tries to get the archived workflow first. Related issue: https://github.com/argoproj/argo-workflows/issues/12814 and Slack thread: https://cloud-native.slack.com/archives/C01QW9QSSSK/p1710600357875049\?thread_ts\=1710510295.856659\&cid\=C01QW9QSSSK Signed-off-by: Ryan Currah --- .../workflow-details/workflow-details.tsx | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx index e6727ec2199d..b1928bd72c6f 100644 --- a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx +++ b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx @@ -384,33 +384,26 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps< // Get workflow useEffect(() => { (async () => { - let archivedWf: Workflow; - if (uid !== '') { - try { - archivedWf = await services.workflows.getArchived(namespace, uid); - setError(null); - } catch (err) { - if (err.status !== 404) { - setError(err); - } - } - } - try { const wf = await services.workflows.get(namespace, name); - setError(null); - // If we find live workflow which has same uid, we use live workflow. - if (!archivedWf || archivedWf.metadata.uid === wf.metadata.uid) { - setWorkflow(wf); - setUid(wf.metadata.uid); - } else { - setWorkflow(archivedWf); - } + setUid(wf.metadata.uid); + setWorkflow(wf); } catch (err) { - if (archivedWf) { - setWorkflow(archivedWf); - } else { + if (err.status !== 404 && uid === '') { setError(err); + return; + } + + try { + const archivedWf = await services.workflows.getArchived(namespace, uid); + setWorkflow(archivedWf); + } catch (archiveErr) { + if (archiveErr.status === 500 && archiveErr.response.body.message === 'getting archived workflows not supported') { + setError(err); + return; + } + + setError(archiveErr); } } })(); From 37a5c8ee848d81c810f231407735f48256dfe282 Mon Sep 17 00:00:00 2001 From: Ryan Currah Date: Tue, 23 Apr 2024 22:01:13 -0400 Subject: [PATCH 2/2] set error to null before returning Signed-off-by: Ryan Currah --- .../components/workflow-details/workflow-details.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx index b1928bd72c6f..d2699bed8da5 100644 --- a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx +++ b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx @@ -388,6 +388,8 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps< const wf = await services.workflows.get(namespace, name); setUid(wf.metadata.uid); setWorkflow(wf); + setError(null); + return; } catch (err) { if (err.status !== 404 && uid === '') { setError(err); @@ -397,6 +399,8 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps< try { const archivedWf = await services.workflows.getArchived(namespace, uid); setWorkflow(archivedWf); + setError(null); + return; } catch (archiveErr) { if (archiveErr.status === 500 && archiveErr.response.body.message === 'getting archived workflows not supported') { setError(err);