mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 13:26:07 +00:00
PR feedback on terminated state checking
This commit is contained in:
parent
ddb9375cb6
commit
953808e899
@ -162,7 +162,9 @@ func (s *Server) StreamResources(stream pbpeerstream.PeerStreamService_StreamRes
|
||||
return grpcstatus.Error(codes.InvalidArgument, "initial subscription for unknown PeerID: "+req.PeerID)
|
||||
}
|
||||
if !p.IsActive() {
|
||||
logger.Warn("peering is marked as deleted or terminated", "peer_id", req.PeerID)
|
||||
// If peering is terminated, then our peer sent the termination message.
|
||||
// For other non-active states, send the termination message.
|
||||
if p.State != pbpeering.PeeringState_TERMINATED {
|
||||
term := &pbpeerstream.ReplicationMessage{
|
||||
Payload: &pbpeerstream.ReplicationMessage_Terminated_{
|
||||
Terminated: &pbpeerstream.ReplicationMessage_Terminated{},
|
||||
@ -172,7 +174,8 @@ func (s *Server) StreamResources(stream pbpeerstream.PeerStreamService_StreamRes
|
||||
|
||||
// we don't care if send fails; stream will be killed by termination message or grpc error
|
||||
_ = stream.Send(term)
|
||||
return grpcstatus.Error(codes.FailedPrecondition, "peering is marked as deleted: "+req.PeerID)
|
||||
}
|
||||
return grpcstatus.Error(codes.Aborted, "peering is marked as deleted: "+req.PeerID)
|
||||
}
|
||||
|
||||
secrets, err := s.GetStore().PeeringSecretsRead(nil, req.PeerID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user