Skip to content

Commit

Permalink
Improve error codes for armadactl. (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
jankaspar committed Sep 10, 2020
1 parent 545e7c6 commit 9d0d88e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions cmd/armadactl/cmd/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ var cancelCmd = &cobra.Command{
Queue: queue,
})
if e != nil {
log.Error(e)
return
exitWithError(e)
}
log.Infof("Cancellation request submitted for jobs: %s", strings.Join(result.CancelledIds, ", "))
})
Expand Down
6 changes: 2 additions & 4 deletions cmd/armadactl/cmd/createQueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ Job priority is evaluated inside queue, queue has its own priority.`,
resourceLimits, _ := cmd.Flags().GetStringToString("resourceLimits")
resourceLimitsFloat, err := convertResourceLimitsToFloat64(resourceLimits)
if err != nil {
log.Error(err)
return
exitWithError(err)
}

apiConnectionDetails := client.ExtractCommandlineArmadaApiConnectionDetails()
Expand All @@ -59,8 +58,7 @@ Job priority is evaluated inside queue, queue has its own priority.`,
ResourceLimits: resourceLimitsFloat})

if e != nil {
log.Error(e)
return
exitWithError(e)
}
log.Infof("Queue %s created.", queue)
})
Expand Down
3 changes: 1 addition & 2 deletions cmd/armadactl/cmd/deleteQueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ var deleteQueueCmd = &cobra.Command{
submissionClient := api.NewSubmitClient(conn)
e := client.DeleteQueue(submissionClient, queue)
if e != nil {
log.Error(e)
return
exitWithError(e)
}
log.Infof("Queue %s deleted or did not exist.", queue)
})
Expand Down
3 changes: 1 addition & 2 deletions cmd/armadactl/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ var infoCmd = &cobra.Command{
defer cancel()
queueInfo, e := submitClient.GetQueueInfo(ctx, &api.QueueInfoRequest{queue})
if e != nil {
log.Error(e)
return
exitWithError(e)
}

jobSets := queueInfo.ActiveJobSets
Expand Down
5 changes: 5 additions & 0 deletions cmd/armadactl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ var cfgFile string
func initConfig() {
client.LoadCommandlineArgsFromConfigFile(cfgFile)
}

func exitWithError(e error) {
log.Error(e)
os.Exit(1)
}
6 changes: 2 additions & 4 deletions cmd/armadactl/cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ var submitCmd = &cobra.Command{
err = util.BindJsonOrYaml(filePath, submitFile)

if err != nil {
log.Error(err)
os.Exit(1)
exitWithError(err)
}

if dryRun {
Expand All @@ -67,8 +66,7 @@ var submitCmd = &cobra.Command{
response, e := client.SubmitJobs(submissionClient, request)

if e != nil {
log.Error(e)
os.Exit(1)
exitWithError(e)
}

summariseResponse(response, request.JobSetId)
Expand Down

0 comments on commit 9d0d88e

Please sign in to comment.