Skip to content

Commit

Permalink
Merge pull request #2018 from aaronlehmann/remove-network-failed-task
Browse files Browse the repository at this point in the history
controlapi: Allow removal of network when only dead tasks reference it
  • Loading branch information
aluzzardi committed Mar 9, 2017
2 parents 58bfef2 + b00598c commit c51357d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions manager/controlapi/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ func (s *Server) RemoveNetwork(ctx context.Context, request *api.RemoveNetworkRe
return grpc.Errorf(codes.Internal, "could not find tasks using network %s: %v", request.NetworkID, err)
}

if len(tasks) != 0 {
return grpc.Errorf(codes.FailedPrecondition, "network %s is in use by task %s", request.NetworkID, tasks[0].ID)
for _, t := range tasks {
if t.DesiredState <= api.TaskStateRunning && t.Status.State <= api.TaskStateRunning {
return grpc.Errorf(codes.FailedPrecondition, "network %s is in use by task %s", request.NetworkID, t.ID)
}
}

nw := store.GetNetwork(tx, request.NetworkID)
Expand Down

0 comments on commit c51357d

Please sign in to comment.