Skip to content

Commit

Permalink
Address some PR suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
  • Loading branch information
timvaillancourt committed Aug 7, 2024
1 parent e18028c commit f3c2e24
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions go/vt/discovery/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ var (
// How much to sleep between each check.
waitAvailableTabletInterval = 100 * time.Millisecond

errKeyspacesToWatchAndTabletFilters = errors.New("Only one of -keyspaces_to_watch and -tablet_filters may be specified at a time")
// errKeyspacesToWatchAndTabletFilters is an error for cases where incompatible filters are defined.
errKeyspacesToWatchAndTabletFilters = errors.New("only one of --keyspaces_to_watch and --tablet_filters may be specified at a time")
)

// See the documentation for NewHealthCheck below for an explanation of these parameters.
Expand Down Expand Up @@ -308,7 +309,7 @@ func NewVTGateHealthCheckFilters() (filters TabletFilters, err error) {

fbs, err := NewFilterByShard(tabletFilters)
if err != nil {
return nil, fmt.Errorf("Cannot parse tablet_filters parameter: %v", err)
return nil, fmt.Errorf("failed to parse tablet_filters value %q: %v", strings.Join(tabletFilters, ","), err)
}
filters = append(filters, fbs)
} else if len(KeyspacesToWatch) > 0 {
Expand Down Expand Up @@ -347,7 +348,7 @@ func NewVTGateHealthCheckFilters() (filters TabletFilters, err error) {
//
// filters.
//
// Is a one or more filters to apply to healthchecks.
// Is one or more filters to apply when determining what tablets we want to stream healthchecks from.
func NewHealthCheck(ctx context.Context, retryDelay, healthCheckTimeout time.Duration, topoServer *topo.Server, localCell, cellsToWatch string, filters TabletFilter) *HealthCheckImpl {
log.Infof("loading tablets for cells: %v", cellsToWatch)

Expand Down
11 changes: 6 additions & 5 deletions go/vt/discovery/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package discovery
import (
"bytes"
"context"
"errors"
"fmt"
"html/template"
"io"
Expand Down Expand Up @@ -77,7 +76,7 @@ func TestNewVTGateHealthCheckFilters(t *testing.T) {
keyspacesToWatch []string
tabletFilters []string
tabletFilterTags map[string]string
expectedError error
expectedError string
expectedFilterTypes []any
}{
{
Expand Down Expand Up @@ -109,12 +108,12 @@ func TestNewVTGateHealthCheckFilters(t *testing.T) {
name: "failKeyspacesToWatchAndFilters",
tabletFilters: []string{"ks1|-80"},
keyspacesToWatch: []string{"ks1"},
expectedError: errKeyspacesToWatchAndTabletFilters,
expectedError: errKeyspacesToWatchAndTabletFilters.Error(),
},
{
name: "failInvalidTabletFilters",
tabletFilters: []string{"shouldfail!@!@#"},
expectedError: errors.New("Cannot parse tablet_filters parameter: invalid FilterByShard parameter: shouldfail!@!@#"),
expectedError: "failed to parse tablet_filters value \"shouldfail!@!@#\": invalid FilterByShard parameter: shouldfail!@!@#",
},
}

Expand All @@ -125,7 +124,9 @@ func TestNewVTGateHealthCheckFilters(t *testing.T) {
tabletFilterTags = testCase.tabletFilterTags

filters, err := NewVTGateHealthCheckFilters()
assert.Equal(t, testCase.expectedError, err)
if testCase.expectedError != "" {
assert.EqualError(t, err, testCase.expectedError)
}
assert.Len(t, filters, len(testCase.expectedFilterTypes))
for i, filter := range filters {
assert.IsType(t, testCase.expectedFilterTypes[i], filter)
Expand Down
9 changes: 9 additions & 0 deletions go/vt/events/eventer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package events

import "vitess.io/vitess/go/vt/proto/vtctldata"

type Eventer interface {
ChangeTabletType() error
EmergencyReparentShard(req *vtctldata.EmergencyReparentShardRequest, resp *vtctldata.EmergencyReparentShardResponse) error
PlannedReparentShard() error
}

0 comments on commit f3c2e24

Please sign in to comment.