mirror of
https://github.com/status-im/consul.git
synced 2025-01-18 17:52:17 +00:00
Distinguish between DC not existing and not being available (#6399)
This commit is contained in:
parent
f356774b71
commit
be50400c62
@ -315,7 +315,11 @@ func (s *Server) getLeader() (bool, *metadata.Server) {
|
|||||||
func (s *Server) forwardDC(method, dc string, args interface{}, reply interface{}) error {
|
func (s *Server) forwardDC(method, dc string, args interface{}, reply interface{}) error {
|
||||||
manager, server, ok := s.router.FindRoute(dc)
|
manager, server, ok := s.router.FindRoute(dc)
|
||||||
if !ok {
|
if !ok {
|
||||||
s.logger.Printf("[WARN] consul.rpc: RPC request for DC %q, no path found", dc)
|
if s.router.HasDatacenter(dc) {
|
||||||
|
s.logger.Printf("[WARN] consul.rpc: RPC request to DC %q is currently failing as no server can be reached", dc)
|
||||||
|
return structs.ErrDCNotAvailable
|
||||||
|
}
|
||||||
|
s.logger.Printf("[WARN] consul.rpc: RPC request for unkown DC %q", dc)
|
||||||
return structs.ErrNoDCPath
|
return structs.ErrNoDCPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,6 +356,14 @@ func (r *Router) GetDatacenters() []string {
|
|||||||
return dcs
|
return dcs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasDatacenter checks whether dc is defined in WAN
|
||||||
|
func (r *Router) HasDatacenter(dc string) bool {
|
||||||
|
r.RLock()
|
||||||
|
defer r.RUnlock()
|
||||||
|
_, ok := r.managers[dc]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// datacenterSorter takes a list of DC names and a parallel vector of distances
|
// datacenterSorter takes a list of DC names and a parallel vector of distances
|
||||||
// and implements sort.Interface, keeping both structures coherent and sorting
|
// and implements sort.Interface, keeping both structures coherent and sorting
|
||||||
// by distance.
|
// by distance.
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
errNoLeader = "No cluster leader"
|
errNoLeader = "No cluster leader"
|
||||||
errNoDCPath = "No path to datacenter"
|
errNoDCPath = "No path to datacenter"
|
||||||
|
errDCNotAvailable = "Remote DC has no server currently reachable"
|
||||||
errNoServers = "No known Consul servers"
|
errNoServers = "No known Consul servers"
|
||||||
errNotReadyForConsistentReads = "Not ready to serve consistent reads"
|
errNotReadyForConsistentReads = "Not ready to serve consistent reads"
|
||||||
errSegmentsNotSupported = "Network segments are not supported in this version of Consul"
|
errSegmentsNotSupported = "Network segments are not supported in this version of Consul"
|
||||||
@ -22,6 +23,7 @@ var (
|
|||||||
ErrNotReadyForConsistentReads = errors.New(errNotReadyForConsistentReads)
|
ErrNotReadyForConsistentReads = errors.New(errNotReadyForConsistentReads)
|
||||||
ErrSegmentsNotSupported = errors.New(errSegmentsNotSupported)
|
ErrSegmentsNotSupported = errors.New(errSegmentsNotSupported)
|
||||||
ErrRPCRateExceeded = errors.New(errRPCRateExceeded)
|
ErrRPCRateExceeded = errors.New(errRPCRateExceeded)
|
||||||
|
ErrDCNotAvailable = errors.New(errDCNotAvailable)
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsErrNoLeader(err error) bool {
|
func IsErrNoLeader(err error) bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user