mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 05:45:46 +00:00
PR feedback on terminated state checking
This commit is contained in:
parent
ddb9375cb6
commit
953808e899
@ -162,17 +162,20 @@ func (s *Server) StreamResources(stream pbpeerstream.PeerStreamService_StreamRes
|
|||||||
return grpcstatus.Error(codes.InvalidArgument, "initial subscription for unknown PeerID: "+req.PeerID)
|
return grpcstatus.Error(codes.InvalidArgument, "initial subscription for unknown PeerID: "+req.PeerID)
|
||||||
}
|
}
|
||||||
if !p.IsActive() {
|
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.
|
||||||
term := &pbpeerstream.ReplicationMessage{
|
// For other non-active states, send the termination message.
|
||||||
Payload: &pbpeerstream.ReplicationMessage_Terminated_{
|
if p.State != pbpeering.PeeringState_TERMINATED {
|
||||||
Terminated: &pbpeerstream.ReplicationMessage_Terminated{},
|
term := &pbpeerstream.ReplicationMessage{
|
||||||
},
|
Payload: &pbpeerstream.ReplicationMessage_Terminated_{
|
||||||
}
|
Terminated: &pbpeerstream.ReplicationMessage_Terminated{},
|
||||||
logTraceSend(logger, term)
|
},
|
||||||
|
}
|
||||||
|
logTraceSend(logger, term)
|
||||||
|
|
||||||
// we don't care if send fails; stream will be killed by termination message or grpc error
|
// we don't care if send fails; stream will be killed by termination message or grpc error
|
||||||
_ = stream.Send(term)
|
_ = 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)
|
secrets, err := s.GetStore().PeeringSecretsRead(nil, req.PeerID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user