diff --git a/pkg/server/status.go b/pkg/server/status.go index 1a2333048ca3..138194b1b5b0 100644 --- a/pkg/server/status.go +++ b/pkg/server/status.go @@ -666,10 +666,17 @@ func (s *statusServer) Details( return nil, grpcstatus.Error(codes.Unavailable, "node is not ready") } - isHealthy, err := s.nodeLiveness.IsHealthy(nodeID) + clock := s.admin.server.clock + l, err := s.nodeLiveness.GetLiveness(nodeID) if err != nil { return nil, grpcstatus.Error(codes.Internal, err.Error()) } + ls := l.LivenessStatus( + clock.PhysicalTime(), + 0, /* threshold */ + clock.MaxOffset(), + ) + isHealthy := ls == storagepb.NodeLivenessStatus_LIVE if !isHealthy { return nil, grpcstatus.Error(codes.Unavailable, "node is not ready") } diff --git a/pkg/storage/node_liveness.go b/pkg/storage/node_liveness.go index 845d3248b2f0..4a8e2c5308b1 100644 --- a/pkg/storage/node_liveness.go +++ b/pkg/storage/node_liveness.go @@ -413,21 +413,6 @@ func (nl *NodeLiveness) IsLive(nodeID roachpb.NodeID) (bool, error) { return liveness.IsLive(nl.clock.Now(), nl.clock.MaxOffset()), nil } -// IsHealthy returns whether or not the specified node IsLive and is in a LIVE -// state, i.e. not draining, decommissioning, or otherwise unhealthy. -func (nl *NodeLiveness) IsHealthy(nodeID roachpb.NodeID) (bool, error) { - liveness, err := nl.GetLiveness(nodeID) - if err != nil { - return false, err - } - ls := liveness.LivenessStatus( - nl.clock.Now().GoTime(), - nl.GetLivenessThreshold(), - nl.clock.MaxOffset(), - ) - return ls == storagepb.NodeLivenessStatus_LIVE, nil -} - // StartHeartbeat starts a periodic heartbeat to refresh this node's // last heartbeat in the node liveness table. The optionally provided // HeartbeatCallback will be invoked whenever this node updates its own liveness. diff --git a/pkg/storage/storagepb/liveness.go b/pkg/storage/storagepb/liveness.go index 4be6559aebec..67757bbd64d9 100644 --- a/pkg/storage/storagepb/liveness.go +++ b/pkg/storage/storagepb/liveness.go @@ -23,8 +23,7 @@ func (l *Liveness) IsLive(now hlc.Timestamp, maxOffset time.Duration) bool { return now.Less(expiration) } -// IsDead returns whether the node is considered dead at the given time with the -// given threshold. +// IsDead returns true if the liveness expired more than threshold ago. func (l *Liveness) IsDead(now hlc.Timestamp, threshold time.Duration) bool { deadAsOf := hlc.Timestamp(l.Expiration).GoTime().Add(threshold) return !now.GoTime().Before(deadAsOf)