Skip to content

Commit

Permalink
Fixed tinkerbell#381: 'tink workflow state' command returns an error …
Browse files Browse the repository at this point in the history
…if workflow does not exist

Signed-off-by: parauliya <aman@infracloud.io>
  • Loading branch information
parauliya committed Mar 4, 2021
1 parent a41538d commit f24c65f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions db/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ func (d TinkDB) GetWorkflow(ctx context.Context, id string) (Workflow, error) {
if err == nil {
return Workflow{ID: id, Template: tmp, Hardware: tar}, nil
}

if err != sql.ErrNoRows {
err = errors.Wrap(err, "SELECT")
d.logger.Error(err)
return Workflow{}, err
}

return Workflow{}, nil
return Workflow{}, errors.New("Workflow with id " + id + " does not exist")
}

// DeleteWorkflow deletes a workflow
Expand Down Expand Up @@ -549,8 +549,9 @@ func (d TinkDB) GetWorkflowContexts(ctx context.Context, wfID string) (*pb.Workf
if err != sql.ErrNoRows {
err = errors.Wrap(err, "SELECT from worflow_state")
d.logger.Error(err)
return &pb.WorkflowContext{}, err
}
return &pb.WorkflowContext{}, nil
return &pb.WorkflowContext{}, errors.New("Workflow with id " + wfID + " does not exist")
}

// GetWorkflowActions : gives you the action list of workflow
Expand Down
4 changes: 2 additions & 2 deletions grpc-server/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func (s *server) GetWorkflow(ctx context.Context, in *workflow.GetRequest) (*wor
l = l.With("detail", pqErr.Detail, "where", pqErr.Where)
}
l.Error(err)
return &workflow.Workflow{}, err
}

fields := map[string]string{
"id": w.Template,
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func (s *server) GetWorkflowContext(ctx context.Context, in *workflow.GetRequest
metrics.CacheInFlight.With(labels).Inc()
defer metrics.CacheInFlight.With(labels).Dec()

const msg = "getting a workflow"
const msg = "getting a workflow context"
labels["op"] = "get"

metrics.CacheTotals.With(labels).Inc()
Expand Down

0 comments on commit f24c65f

Please sign in to comment.