mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Make API access determing system not available consistent.
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -841,7 +841,7 @@ func (s *Server) jsAccountInfoRequest(sub *subscription, c *client, subject, rep
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -1113,7 +1113,7 @@ func (s *Server) jsStreamCreateRequest(sub *subscription, c *client, subject, re
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -1221,7 +1221,7 @@ func (s *Server) jsStreamUpdateRequest(sub *subscription, c *client, subject, re
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -1301,7 +1301,7 @@ func (s *Server) jsStreamNamesRequest(sub *subscription, c *client, subject, rep
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -1425,7 +1425,7 @@ func (s *Server) jsStreamListRequest(sub *subscription, c *client, subject, repl
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -1602,8 +1602,7 @@ func (s *Server) jsStreamLeaderStepDownRequest(sub *subscription, c *client, sub
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -1687,8 +1686,7 @@ func (s *Server) jsConsumerLeaderStepDownRequest(sub *subscription, c *client, s
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -1788,8 +1786,7 @@ func (s *Server) jsStreamRemovePeerRequest(sub *subscription, c *client, subject
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -2041,7 +2038,7 @@ func (s *Server) jsStreamDeleteRequest(sub *subscription, c *client, subject, re
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -2109,8 +2106,7 @@ func (s *Server) jsMsgDeleteRequest(sub *subscription, c *client, subject, reply
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -2215,8 +2211,7 @@ func (s *Server) jsMsgGetRequest(sub *subscription, c *client, subject, reply st
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -2858,7 +2853,7 @@ func (s *Server) jsConsumerCreate(sub *subscription, c *client, subject, reply s
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -2956,7 +2951,7 @@ func (s *Server) jsConsumerNamesRequest(sub *subscription, c *client, subject, r
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -3075,7 +3070,7 @@ func (s *Server) jsConsumerListRequest(sub *subscription, c *client, subject, re
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
@@ -3259,7 +3254,7 @@ func (s *Server) jsConsumerDeleteRequest(sub *subscription, c *client, subject,
|
||||
if js == nil || cc == nil {
|
||||
return
|
||||
}
|
||||
if cc.meta != nil && cc.meta.GroupLeader() == _EMPTY_ {
|
||||
if js.isLeaderless() {
|
||||
resp.Error = jsClusterNotAvailErr
|
||||
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
|
||||
@@ -546,16 +546,14 @@ func (js *jetStream) isLeaderless() bool {
|
||||
defer js.mu.RUnlock()
|
||||
|
||||
cc := js.cluster
|
||||
if cc == nil {
|
||||
if cc == nil || cc.meta == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// If we don't have a leader.
|
||||
if cc.meta.GroupLeader() == _EMPTY_ {
|
||||
// Make sure we have been running for enough time.
|
||||
if time.Since(cc.meta.Created()) > lostQuorumInterval {
|
||||
return true
|
||||
}
|
||||
// Make sure we have been running for enough time.
|
||||
if cc.meta.GroupLeader() == _EMPTY_ && time.Since(cc.meta.Created()) > lostQuorumInterval {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user