catalog: block unsupported failover policy settings for now (#19168)

This commit is contained in:
R.B. Boyer 2023-10-12 11:13:56 -05:00 committed by GitHub
parent 6da4798e05
commit 29ba5b5c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 13 deletions

View File

@ -173,6 +173,14 @@ func validateFailoverConfig(config *pbcatalog.FailoverConfig, ported bool, wrapE
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
if (len(config.Destinations) > 0) == (config.SamenessGroup != "") {
@ -194,18 +202,26 @@ func validateFailoverConfig(config *pbcatalog.FailoverConfig, ported bool, wrapE
}
}
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:
if config.Mode != pbcatalog.FailoverMode_FAILOVER_MODE_UNSPECIFIED {
merr = multierror.Append(merr, wrapErr(resource.ErrInvalidField{
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
return merr

View File

@ -253,15 +253,30 @@ func TestValidateFailoverPolicy(t *testing.T) {
// TODO(v2): remove after this is supported
expectErr: `invalid "sameness_group" field: not supported in this release`,
},
"mode: invalid": {
"regions without dest": {
config: &pbcatalog.FailoverConfig{
Mode: 99,
Destinations: []*pbcatalog.FailoverDestination{
{Ref: newRef(pbcatalog.ServiceType, "api-backup")},
Regions: []string{"us-east1", "us-west2"},
},
// 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": {
config: &pbcatalog.FailoverConfig{
Destinations: []*pbcatalog.FailoverDestination{