mirror of https://github.com/status-im/consul.git
rpc: Unset partition before forwarding to remote datacenter (#11758)
This commit is contained in:
parent
a031de21c0
commit
7a365fa0da
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
rpc: unset partition before forwarding to remote datacenter
|
||||||
|
```
|
|
@ -89,6 +89,19 @@ const (
|
||||||
|
|
||||||
var ErrChunkingResubmit = errors.New("please resubmit call for rechunking")
|
var ErrChunkingResubmit = errors.New("please resubmit call for rechunking")
|
||||||
|
|
||||||
|
// partitionUnsetter is used to describe requests values that can unset their
|
||||||
|
// EnterpriseMeta.Partition value.
|
||||||
|
type partitionUnsetter interface {
|
||||||
|
// UnsetPartition is used to strip a Partition value from the request before
|
||||||
|
// it is forwarded to a remote datacenter. By unsetting the value, the server
|
||||||
|
// that handles the request can decide which partition should be used (or do nothing).
|
||||||
|
// This ensures that servers that are Partition-enabled (pre-1.11, or non-Enterprise)
|
||||||
|
// don't inadvertently cause servers that are not Partition-enabled (<= 1.10 or non-Enterprise)
|
||||||
|
// to filter their responses by Partition. In other words, this ensures upgraded servers
|
||||||
|
// remain compatible with non-upgraded servers.
|
||||||
|
UnsetPartition()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) rpcLogger() hclog.Logger {
|
func (s *Server) rpcLogger() hclog.Logger {
|
||||||
return s.loggers.Named(logging.RPC)
|
return s.loggers.Named(logging.RPC)
|
||||||
}
|
}
|
||||||
|
@ -655,6 +668,14 @@ func (s *Server) forwardRequestToOtherDatacenter(info structs.RPCInfo, forwardTo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// In order to interoperate with servers that can interpret Partition, but
|
||||||
|
// may not handle it correctly (eg. 1.10 servers), we need to unset the value.
|
||||||
|
// Unsetting the Partition ensures that the server that handles the request
|
||||||
|
// uses its Partition, or an empty value (aka doing nothing).
|
||||||
|
// For requests that are not Partition-aware, this is a no-op.
|
||||||
|
if v, ok := info.(partitionUnsetter); ok {
|
||||||
|
v.UnsetPartition()
|
||||||
|
}
|
||||||
|
|
||||||
return true, forwardToDC(dc)
|
return true, forwardToDC(dc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@ func (m *EnterpriseMeta) WithWildcardNamespace() *EnterpriseMeta {
|
||||||
return &emptyEnterpriseMeta
|
return &emptyEnterpriseMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *EnterpriseMeta) UnsetPartition() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(partition): stop using this
|
// TODO(partition): stop using this
|
||||||
func NewEnterpriseMetaInDefaultPartition(_ string) EnterpriseMeta {
|
func NewEnterpriseMetaInDefaultPartition(_ string) EnterpriseMeta {
|
||||||
return emptyEnterpriseMeta
|
return emptyEnterpriseMeta
|
||||||
|
|
Loading…
Reference in New Issue