Skip to content

Commit

Permalink
add missing taskDone for graceful term (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwinger233 authored Jun 24, 2021
1 parent 1664108 commit d33f2fc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ func (v *Vibranium) GetWorkloads(ctx context.Context, cids *pb.WorkloadIDs) (*pb
// ListWorkloads by appname with optional entrypoint and nodename
func (v *Vibranium) ListWorkloads(opts *pb.ListWorkloadsOptions, stream pb.CoreRPC_ListWorkloadsServer) error {
ctx := v.taskAdd(stream.Context(), "ListWorkloads", true)
defer v.taskDone(ctx, "ListWorkloads", true)
lsopts := &types.ListWorkloadsOptions{
Appname: opts.Appname,
Entrypoint: opts.Entrypoint,
Expand Down Expand Up @@ -831,16 +832,19 @@ func (v *Vibranium) RunAndWait(stream pb.CoreRPC_RunAndWaitServer) error {
ctx := v.taskAdd(stream.Context(), "RunAndWait", true)
RunAndWaitOptions, err := stream.Recv()
if err != nil {
v.taskDone(ctx, "RunAndWait", true)
return grpcstatus.Error(RunAndWait, err.Error())
}

if RunAndWaitOptions.DeployOptions == nil {
v.taskDone(ctx, "RunAndWait", true)
return grpcstatus.Error(RunAndWait, types.ErrNoDeployOpts.Error())
}

opts := RunAndWaitOptions.DeployOptions
deployOpts, err := toCoreDeployOptions(opts)
if err != nil {
v.taskDone(ctx, "RunAndWait", true)
return grpcstatus.Error(RunAndWait, err.Error())
}

Expand Down Expand Up @@ -873,6 +877,7 @@ func (v *Vibranium) RunAndWait(stream pb.CoreRPC_RunAndWaitServer) error {

ids, ch, err := v.cluster.RunAndWait(ctx, deployOpts, inCh)
if err != nil {
v.taskDone(ctx, "RunAndWait", true)
cancel()
return grpcstatus.Error(RunAndWait, err.Error())
}
Expand Down

0 comments on commit d33f2fc

Please sign in to comment.