mirror of
https://github.com/status-im/consul.git
synced 2025-02-19 17:14:37 +00:00
handle error scenario of empty local DC
This commit is contained in:
parent
af29cda415
commit
5c121d7a48
@ -598,6 +598,10 @@ func gateWriteToSecondary(targetDC, localDC, primaryDC, kind string) error {
|
|||||||
if kind != structs.PartitionExports {
|
if kind != structs.PartitionExports {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if localDC == "" {
|
||||||
|
// This should not happen because the datacenter is defaulted in DefaultConfig.
|
||||||
|
return fmt.Errorf("unknown local datacenter")
|
||||||
|
}
|
||||||
|
|
||||||
if primaryDC == "" {
|
if primaryDC == "" {
|
||||||
primaryDC = localDC
|
primaryDC = localDC
|
||||||
|
@ -2151,6 +2151,14 @@ func Test_gateWriteToSecondary(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantErr: "must target the primary datacenter explicitly",
|
wantErr: "must target the primary datacenter explicitly",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "empty local DC",
|
||||||
|
args: args{
|
||||||
|
localDC: "",
|
||||||
|
kind: structs.PartitionExports,
|
||||||
|
},
|
||||||
|
wantErr: "unknown local datacenter",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range tt {
|
for _, tc := range tt {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user