mirror of
https://github.com/status-im/consul.git
synced 2025-01-20 18:50:04 +00:00
catalog: block unsupported failover policy settings for now (#19168)
This commit is contained in:
parent
6da4798e05
commit
29ba5b5c79
@ -173,6 +173,14 @@ func validateFailoverConfig(config *pbcatalog.FailoverConfig, ported bool, wrapE
|
|||||||
Wrapped: fmt.Errorf("not supported in this release"),
|
Wrapped: fmt.Errorf("not supported in this release"),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(config.Regions) > 0 {
|
||||||
|
merr = multierror.Append(merr, wrapErr(resource.ErrInvalidField{
|
||||||
|
Name: "regions",
|
||||||
|
Wrapped: fmt.Errorf("not supported in this release"),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(peering/v2): remove this bypass when we know what to do with
|
// TODO(peering/v2): remove this bypass when we know what to do with
|
||||||
|
|
||||||
if (len(config.Destinations) > 0) == (config.SamenessGroup != "") {
|
if (len(config.Destinations) > 0) == (config.SamenessGroup != "") {
|
||||||
@ -194,18 +202,26 @@ func validateFailoverConfig(config *pbcatalog.FailoverConfig, ported bool, wrapE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch config.Mode {
|
if config.Mode != pbcatalog.FailoverMode_FAILOVER_MODE_UNSPECIFIED {
|
||||||
case pbcatalog.FailoverMode_FAILOVER_MODE_UNSPECIFIED:
|
|
||||||
// means pbcatalog.FailoverMode_FAILOVER_MODE_SEQUENTIAL
|
|
||||||
case pbcatalog.FailoverMode_FAILOVER_MODE_SEQUENTIAL:
|
|
||||||
case pbcatalog.FailoverMode_FAILOVER_MODE_ORDER_BY_LOCALITY:
|
|
||||||
default:
|
|
||||||
merr = multierror.Append(merr, wrapErr(resource.ErrInvalidField{
|
merr = multierror.Append(merr, wrapErr(resource.ErrInvalidField{
|
||||||
Name: "mode",
|
Name: "mode",
|
||||||
Wrapped: fmt.Errorf("not a supported enum value: %v", config.Mode),
|
Wrapped: fmt.Errorf("not supported in this release"),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(v2): uncomment after this is supported
|
||||||
|
// switch config.Mode {
|
||||||
|
// case pbcatalog.FailoverMode_FAILOVER_MODE_UNSPECIFIED:
|
||||||
|
// // means pbcatalog.FailoverMode_FAILOVER_MODE_SEQUENTIAL
|
||||||
|
// case pbcatalog.FailoverMode_FAILOVER_MODE_SEQUENTIAL:
|
||||||
|
// case pbcatalog.FailoverMode_FAILOVER_MODE_ORDER_BY_LOCALITY:
|
||||||
|
// default:
|
||||||
|
// merr = multierror.Append(merr, wrapErr(resource.ErrInvalidField{
|
||||||
|
// Name: "mode",
|
||||||
|
// Wrapped: fmt.Errorf("not a supported enum value: %v", config.Mode),
|
||||||
|
// }))
|
||||||
|
// }
|
||||||
|
|
||||||
// TODO: validate sameness group requirements
|
// TODO: validate sameness group requirements
|
||||||
|
|
||||||
return merr
|
return merr
|
||||||
|
@ -253,15 +253,30 @@ func TestValidateFailoverPolicy(t *testing.T) {
|
|||||||
// TODO(v2): remove after this is supported
|
// TODO(v2): remove after this is supported
|
||||||
expectErr: `invalid "sameness_group" field: not supported in this release`,
|
expectErr: `invalid "sameness_group" field: not supported in this release`,
|
||||||
},
|
},
|
||||||
"mode: invalid": {
|
"regions without dest": {
|
||||||
config: &pbcatalog.FailoverConfig{
|
config: &pbcatalog.FailoverConfig{
|
||||||
Mode: 99,
|
Regions: []string{"us-east1", "us-west2"},
|
||||||
Destinations: []*pbcatalog.FailoverDestination{
|
|
||||||
{Ref: newRef(pbcatalog.ServiceType, "api-backup")},
|
|
||||||
},
|
},
|
||||||
|
// TODO(v2): remove after this is supported
|
||||||
|
expectErr: `invalid "regions" field: not supported in this release`,
|
||||||
},
|
},
|
||||||
expectErr: `invalid "mode" field: not a supported enum value: 99`,
|
"mode without dest": {
|
||||||
|
config: &pbcatalog.FailoverConfig{
|
||||||
|
Mode: pbcatalog.FailoverMode_FAILOVER_MODE_SEQUENTIAL,
|
||||||
},
|
},
|
||||||
|
// TODO(v2): remove after this is supported
|
||||||
|
expectErr: `invalid "mode" field: not supported in this release`,
|
||||||
|
},
|
||||||
|
// TODO(v2): uncomment after this is supported
|
||||||
|
// "mode: invalid": {
|
||||||
|
// config: &pbcatalog.FailoverConfig{
|
||||||
|
// Mode: 99,
|
||||||
|
// Destinations: []*pbcatalog.FailoverDestination{
|
||||||
|
// {Ref: newRef(pbcatalog.ServiceType, "api-backup")},
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// expectErr: `invalid "mode" field: not a supported enum value: 99`,
|
||||||
|
// },
|
||||||
"dest: no ref": {
|
"dest: no ref": {
|
||||||
config: &pbcatalog.FailoverConfig{
|
config: &pbcatalog.FailoverConfig{
|
||||||
Destinations: []*pbcatalog.FailoverDestination{
|
Destinations: []*pbcatalog.FailoverDestination{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user