From 5b4a40fc96a9714035ecd512e565decca2da292d Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Thu, 24 Nov 2022 10:26:46 +0100 Subject: [PATCH] api: allow cancelling of orphaned jobs --- api/graph/schema.resolvers.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go index 57c4089..41541cb 100644 --- a/api/graph/schema.resolvers.go +++ b/api/graph/schema.resolvers.go @@ -405,7 +405,12 @@ func (r *mutationResolver) Cancel(ctx context.Context, jobID int) (*model.Job, e if err != nil { return err } - if resp.StatusCode != 200 { + + // If the job was found like this in the database, but the + // runner does not know about it, then something is wrong (e.g. + // the runner crashed and rebooted). Go ahead and set it to + // cancelled, so that it does not block anything. + if resp.StatusCode != 200 && resp.StatusCode != 404 { return fmt.Errorf("Failed to cancel job") } -- 2.38.5