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

mark running jobs as failed on exc k8s restart #3642

Merged
merged 2 commits into from
Jun 14, 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
13 changes: 13 additions & 0 deletions packages/teraslice/src/lib/cluster/services/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ export class ExecutionService {
return;
}

const runningStatuses = this.executionStorage.getRunningStatuses();

if (runningStatuses.includes(status)) {
// This should never happen. If we get here with a running status
// something has gone wrong. Mark execution as failed before shutdown.
this.logger.warn(`Cluster_master is changing status of execution ${exId} from ${status} to failed`);
await this.executionStorage.setStatus(
exId,
'failed',
this.executionStorage.executionMetaData(null, getFullErrorStack(err))
);
}

this.logger.debug(`execution ${exId} finished, shutting down execution`);

try {
Expand Down
11 changes: 10 additions & 1 deletion packages/teraslice/src/lib/workers/execution-controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,13 +899,22 @@ export class ExecutionController {

const invalidStateMsg = (state: string) => {
const prefix = `Execution ${this.exId} was starting in ${state} status`;
return `${prefix} sending execution:finished event to cluster master`;
return `${prefix}, sending execution:finished event to cluster master`;
};

if (includes(terminalStatuses, status)) {
error = new Error(invalidStateMsg('terminal'));
} else if (includes(runningStatuses, status)) {
error = new Error(invalidStateMsg('running'));
// If in a running status the execution process
// crashed and k8s is trying to restart the pod,
// e.g. execution controller OOM.
this.logger.warn(`Changing execution status from ${status} to failed`);
await this.executionStorage.setStatus(
this.exId,
'failed',
this.executionStorage.executionMetaData(null, getFullErrorStack(error))
);
} else {
return true;
}
Expand Down
Loading