Skip to content

Commit 9e6937d

Browse files
committed
db: add validation for WALFailover options
Informs cockroachdb/cockroach#147807
1 parent e8d7ecb commit 9e6937d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

options.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,13 @@ type WALFailoverOptions struct {
14181418
wal.FailoverOptions
14191419
}
14201420

1421+
func (o *WALFailoverOptions) Validate() error {
1422+
if o.Secondary.FS == nil {
1423+
return errors.New("Secondary.FS is required")
1424+
}
1425+
return nil
1426+
}
1427+
14211428
// ReadaheadConfig controls the use of read-ahead.
14221429
type ReadaheadConfig = objstorageprovider.ReadaheadConfig
14231430

@@ -2592,6 +2599,12 @@ func (o *Options) Validate() error {
25922599
}
25932600
}
25942601

2602+
if o.WALFailover != nil {
2603+
if err := o.WALFailover.Validate(); err != nil {
2604+
fmt.Fprintf(&buf, "WALFailover validation failed: %v\n", err)
2605+
}
2606+
}
2607+
25952608
if buf.Len() == 0 {
25962609
return nil
25972610
}

options_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,14 @@ func TestOptionsValidate(t *testing.T) {
547547
}
548548
})
549549
}
550+
t.Run("wal-failover", func(t *testing.T) {
551+
var opts Options
552+
opts.EnsureDefaults()
553+
opts.WALFailover = &WALFailoverOptions{}
554+
err := opts.Validate()
555+
require.Error(t, err)
556+
require.Regexp(t, "Secondary.FS is required", err.Error())
557+
})
550558
}
551559

552560
func TestKeyCategories(t *testing.T) {

0 commit comments

Comments
 (0)