From 59c86971cfaae1850a36a5b162e12206f94831d7 Mon Sep 17 00:00:00 2001 From: Bruce Schultz Date: Thu, 19 Sep 2024 11:47:31 +0200 Subject: [PATCH 1/4] feat(status): manually check each pod to see if running on node build_image --- components/analysis/AnalysesTable.vue | 35 +++++++++++++++++-- .../analysis/AnalysisControlButtons.vue | 8 ++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/components/analysis/AnalysesTable.vue b/components/analysis/AnalysesTable.vue index 7a1d250..d7defbf 100644 --- a/components/analysis/AnalysesTable.vue +++ b/components/analysis/AnalysesTable.vue @@ -12,9 +12,10 @@ import { getRunStatusSeverity, } from "~/utils/status-tag-severity"; import { + AnalysisBuildStatus, AnalysisNodeRunStatus, + AnalysisRunStatus, ApprovalStatus, - AnalysisBuildStatus, } from "~/services/Api"; const expandedRows = ref(); @@ -40,6 +41,35 @@ function parseData() { } parseData(); +// TODO: remove +function checkRunStatuses() { + const analysesData = response.value!.data; + for (const analysisNode of analysesData) { + if ( + analysisNode.analysis?.build_status === AnalysisBuildStatus.Finished && + !analysisNode.run_status + ) { + const analysisId = analysisNode.analysis_id; + + useLazyFetch(`/po/${analysisId}/pods`, { + $fetch: useNuxtApp().$hubApi, + }) + .then(({ data: prevLogResp, status: podCheckStatus }) => { + watch(prevLogResp, () => { + if ( + podCheckStatus.value === "success" && + prevLogResp.value.pods.length > 0 + ) { + updateRunStatus(analysisNode.id, AnalysisRunStatus.Running); + } + }); + }) + .catch((error) => console.error(error)); + } + } +} +checkRunStatuses(); + function onToggleRowExpansion(rowIds) { expandedRows.value = rowIds; } @@ -47,6 +77,7 @@ function onToggleRowExpansion(rowIds) { async function onTableRefresh() { await refresh(); parseData(); + checkRunStatuses(); // TODO: remove } // Table filters @@ -82,7 +113,7 @@ function updateRunStatus(analysisNodeId: string, newStatus: string) { for (let row of analyses.value) { if (row.id === analysisNodeId) { row.run_status = newStatus; - return; + break; } } } diff --git a/components/analysis/AnalysisControlButtons.vue b/components/analysis/AnalysisControlButtons.vue index 429f8a0..ec2dd20 100644 --- a/components/analysis/AnalysisControlButtons.vue +++ b/components/analysis/AnalysisControlButtons.vue @@ -29,6 +29,7 @@ const stopButtonActiveStates = [ AnalysisNodeRunStatus.Running, AnalysisNodeRunStatus.Starting, AnalysisNodeRunStatus.Started, + AnalysisNodeRunStatus.Stopping, ]; const deleteButtonActiveStates = [ AnalysisNodeRunStatus.Failed, @@ -40,7 +41,12 @@ const deleteButtonActiveStates = [ AnalysisNodeRunStatus.Started, ]; -const buttonStatuses = ref(setButtonStatuses(props.analysisRunStatus!)); +const buttonStatuses = ref(setButtonStatuses(props.analysisRunStatus)); + +// TODO: possibly remove when manual pod status checks are removed +watch(props, () => { + buttonStatuses.value = setButtonStatuses(props.analysisRunStatus); +}); function setButtonStatuses(podStatus: string) { emit("newRunStatus", props.analysisNodeId, podStatus); From a2287276a49a9af1f22bf31a7361f8a0ec610ba1 Mon Sep 17 00:00:00 2001 From: Bruce Schultz Date: Thu, 19 Sep 2024 12:43:34 +0200 Subject: [PATCH 2/4] ci(pr): update workflow to include PRs build_image --- .github/workflows/build-push-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-push-docker.yml b/.github/workflows/build-push-docker.yml index 4e3625d..795dd1c 100644 --- a/.github/workflows/build-push-docker.yml +++ b/.github/workflows/build-push-docker.yml @@ -3,7 +3,7 @@ name: Create and publish Docker image on: push: branches: - - develop + - "*" pull_request: types: [ "closed" ] branches: @@ -15,7 +15,7 @@ env: jobs: build-and-push-image: - if: contains(github.event.head_commit.message, 'build_image') + if: ${{ (github.event.pull_request.merged) || (contains(github.event.head_commit.message, 'build_image')) }} runs-on: ubuntu-latest permissions: contents: read From 51c97e72b925e85e2d16772fef5665bca21d0b95 Mon Sep 17 00:00:00 2001 From: Bruce Schultz Date: Thu, 19 Sep 2024 12:44:29 +0200 Subject: [PATCH 3/4] revert(workflow): revert allowed push branch for trigger --- .github/workflows/build-push-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-docker.yml b/.github/workflows/build-push-docker.yml index 795dd1c..8f9515d 100644 --- a/.github/workflows/build-push-docker.yml +++ b/.github/workflows/build-push-docker.yml @@ -3,7 +3,7 @@ name: Create and publish Docker image on: push: branches: - - "*" + - develop pull_request: types: [ "closed" ] branches: From 8f830073cd41e0b55bebfa3d2cf5d9c9b51cea91 Mon Sep 17 00:00:00 2001 From: Bruce Schultz Date: Thu, 19 Sep 2024 13:51:33 +0200 Subject: [PATCH 4/4] fix(middleware): disable rerouting if response is 403 --- plugins/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/api.ts b/plugins/api.ts index 34b29d6..f7edf2d 100644 --- a/plugins/api.ts +++ b/plugins/api.ts @@ -23,7 +23,7 @@ export default defineNuxtPlugin(() => { }, async onResponseError({ request, response }) { // Handle the response errors - if (response.status === 401 || response.status === 403) { + if (response.status === 401) { console.warn("User not signed in, returning to login"); return login(); }