-
Notifications
You must be signed in to change notification settings - Fork 134
/
cancel.go
36 lines (29 loc) · 1.16 KB
/
cancel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package armadactl
import (
"fmt"
"strings"
"github.com/pkg/errors"
"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/pkg/api"
"github.com/armadaproject/armada/pkg/client"
)
// Cancel cancels a job.
// TODO this method does too much; there should be separate methods to cancel individual jobs and all jobs in a job set
func (a *App) Cancel(queue string, jobSetId string, jobId string) (outerErr error) {
apiConnectionDetails := a.Params.ApiConnectionDetails
fmt.Fprintf(a.Out, "Requesting cancellation of jobs matching queue: %s, job set: %s, and job ID: %s\n", queue, jobSetId, jobId)
return client.WithSubmitClient(apiConnectionDetails, func(c api.SubmitClient) error {
ctx, cancel := common.ContextWithDefaultTimeout()
defer cancel()
result, err := c.CancelJobs(ctx, &api.JobCancelRequest{
JobId: jobId,
JobSetId: jobSetId,
Queue: queue,
})
if err != nil {
return errors.Wrapf(err, "error cancelling jobs matching queue: %s, job set: %s, and job id: %s", queue, jobSetId, jobId)
}
fmt.Fprintf(a.Out, "Requested cancellation for jobs %s\n", strings.Join(result.CancelledIds, ", "))
return nil
})
}