Remove support for failover to partition

Failing over to a partition is more siimilar to failing over to another
datacenter than it is to failing over to a namespace. In a future
release we should update how localities for failover are specified. We
should be able to accept a list of localities which can include both
partition and datacenter.
This commit is contained in:
freddygv 2021-12-06 11:31:05 -07:00
parent a1c1e36be7
commit 65875a7c69
3 changed files with 7 additions and 17 deletions

View File

@ -989,7 +989,7 @@ RESOLVE_AGAIN:
target,
failover.Service,
failover.ServiceSubset,
failover.Partition,
target.Partition,
failover.Namespace,
dc,
)
@ -1003,7 +1003,7 @@ RESOLVE_AGAIN:
target,
failover.Service,
failover.ServiceSubset,
failover.Partition,
target.Partition,
failover.Namespace,
"",
)

View File

@ -946,7 +946,7 @@ func (e *ServiceResolverConfigEntry) Validate() error {
if e.Redirect != nil {
if !e.InDefaultPartition() && e.Redirect.Datacenter != "" {
return fmt.Errorf("Cross-datacenter redirect is not supported in non-default partitions")
return fmt.Errorf("Cross-datacenter redirect is only supported in the default partition")
}
if PartitionOrDefault(e.Redirect.Partition) != e.PartitionOrDefault() && e.Redirect.Datacenter != "" {
return fmt.Errorf("Cross-datacenter and cross-partition redirect is not supported")
@ -985,18 +985,15 @@ func (e *ServiceResolverConfigEntry) Validate() error {
for subset, f := range e.Failover {
if !e.InDefaultPartition() && len(f.Datacenters) != 0 {
return fmt.Errorf("Cross-datacenter failover is not supported in non-default partitions")
}
if PartitionOrDefault(f.Partition) != e.PartitionOrDefault() && len(f.Datacenters) != 0 {
return fmt.Errorf("Cross-datacenter and cross-partition failover is not supported")
return fmt.Errorf("Cross-datacenter failover is only supported in the default partition")
}
if subset != "*" && !isSubset(subset) {
return fmt.Errorf("Bad Failover[%q]: not a valid subset", subset)
}
if f.Service == "" && f.ServiceSubset == "" && f.Namespace == "" && f.Partition == "" && len(f.Datacenters) == 0 {
return fmt.Errorf("Bad Failover[%q] one of Service, ServiceSubset, Namespace, Partition, or Datacenters is required", subset)
if f.Service == "" && f.ServiceSubset == "" && f.Namespace == "" && len(f.Datacenters) == 0 {
return fmt.Errorf("Bad Failover[%q] one of Service, ServiceSubset, Namespace, or Datacenters is required", subset)
}
if f.ServiceSubset != "" {
@ -1202,13 +1199,6 @@ type ServiceResolverFailover struct {
// This is a DESTINATION during failover.
Namespace string `json:",omitempty"`
// Partition is the partition to resolve the requested service from to form
// the failover group of instances. If empty the current partition is used
// (optional).
//
// This is a DESTINATION during failover.
Partition string `json:",omitempty"`
// Datacenters is a fixed list of datacenters to try. We never try a
// datacenter multiple times, so those are subtracted from this list before
// proceeding.

View File

@ -695,7 +695,7 @@ func TestServiceResolverConfigEntry(t *testing.T) {
"v1": {},
},
},
validateErr: `Bad Failover["v1"] one of Service, ServiceSubset, Namespace, Partition, or Datacenters is required`,
validateErr: `Bad Failover["v1"] one of Service, ServiceSubset, Namespace, or Datacenters is required`,
},
{
name: "failover to self using invalid subset",