Skip to content

Commit

Permalink
Merge pull request #106 from PrivateAIM/105-manually-check-for-runnin…
Browse files Browse the repository at this point in the history
…g-pods

105 manually check for running pods
  • Loading branch information
brucetony authored Sep 19, 2024
2 parents cfa2c4d + 8f83007 commit 59600bb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-push-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 33 additions & 2 deletions components/analysis/AnalysesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
getRunStatusSeverity,
} from "~/utils/status-tag-severity";
import {
AnalysisBuildStatus,
AnalysisNodeRunStatus,
AnalysisRunStatus,
ApprovalStatus,
AnalysisBuildStatus,
} from "~/services/Api";
const expandedRows = ref();
Expand All @@ -40,13 +41,43 @@ 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;
}
async function onTableRefresh() {
await refresh();
parseData();
checkRunStatuses(); // TODO: remove
}
// Table filters
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion components/analysis/AnalysisControlButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const stopButtonActiveStates = [
AnalysisNodeRunStatus.Running,
AnalysisNodeRunStatus.Starting,
AnalysisNodeRunStatus.Started,
AnalysisNodeRunStatus.Stopping,
];
const deleteButtonActiveStates = [
AnalysisNodeRunStatus.Failed,
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 59600bb

Please sign in to comment.