Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

105 manually check for running pods #106

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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