Skip to content

Commit 3967f96

Browse files
committed
ignore abort during cleanup
1 parent 34e4a64 commit 3967f96

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

apps/coordinator/src/exec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ export class Exec {
3939
this.trimArgs = opts.trimArgs ?? true;
4040
}
4141

42-
async x(command: string, args?: string[], opts?: { neverThrow?: boolean }) {
42+
async x(
43+
command: string,
44+
args?: string[],
45+
opts?: { neverThrow?: boolean; ignoreAbort?: boolean }
46+
) {
4347
const argsTrimmed = this.trimArgs ? args?.map((arg) => arg.trim()) : args;
4448

4549
const commandWithFirstArg = `${command}${argsTrimmed?.length ? ` ${argsTrimmed[0]}` : ""}`;
4650
this.logger.debug(`exec: ${commandWithFirstArg}`, { command, args, argsTrimmed });
4751

4852
const result = x(command, argsTrimmed, {
49-
signal: this.abortSignal,
53+
signal: opts?.ignoreAbort ? undefined : this.abortSignal,
5054
// We don't use this as it doesn't cover killed and aborted processes
5155
// throwOnError: true,
5256
});
@@ -157,7 +161,7 @@ export class Buildah {
157161
async cleanup() {
158162
if (this.containers.size > 0) {
159163
try {
160-
const output = await this.x("buildah", ["rm", ...this.containers]);
164+
const output = await this.x("buildah", ["rm", ...this.containers], { ignoreAbort: true });
161165
this.containers.clear();
162166

163167
if (output.stderr.length > 0) {
@@ -172,7 +176,7 @@ export class Buildah {
172176

173177
if (this.images.size > 0) {
174178
try {
175-
const output = await this.x("buildah", ["rmi", ...this.images]);
179+
const output = await this.x("buildah", ["rmi", ...this.images], { ignoreAbort: true });
176180
this.images.clear();
177181

178182
if (output.stderr.length > 0) {
@@ -251,7 +255,7 @@ export class Crictl {
251255
async cleanup() {
252256
if (this.archives.size > 0) {
253257
try {
254-
const output = await this.x("rm", ["-v", ...this.archives]);
258+
const output = await this.x("rm", ["-v", ...this.archives], { ignoreAbort: true });
255259
this.archives.clear();
256260

257261
if (output.stderr.length > 0) {

0 commit comments

Comments
 (0)