diff --git a/go/vt/discovery/healthcheck.go b/go/vt/discovery/healthcheck.go index 8be547913d9..d37b7419fd6 100644 --- a/go/vt/discovery/healthcheck.go +++ b/go/vt/discovery/healthcheck.go @@ -320,6 +320,9 @@ func NewVTGateHealthCheckFilters() (filters TabletFilters, err error) { } else if len(KeyspacesToWatch) > 0 { filters = append(filters, NewFilterByKeyspace(KeyspacesToWatch)) } + if len(tabletFilterTags) > 0 { + filters = append(filters, NewFilterByTabletTags(tabletFilterTags)) + } return filters, nil } diff --git a/go/vt/discovery/healthcheck_test.go b/go/vt/discovery/healthcheck_test.go index 51a43c454b3..fa7c497c146 100644 --- a/go/vt/discovery/healthcheck_test.go +++ b/go/vt/discovery/healthcheck_test.go @@ -67,12 +67,14 @@ func TestNewVTGateHealthCheckFilters(t *testing.T) { defer func() { KeyspacesToWatch = nil tabletFilters = nil + tabletFilterTags = nil }() testCases := []struct { name string keyspacesToWatch []string tabletFilters []string + tabletFilterTags map[string]string expectedError string expectedFilterTypes []any }{ @@ -89,6 +91,18 @@ func TestNewVTGateHealthCheckFilters(t *testing.T) { keyspacesToWatch: []string{"ks1"}, expectedFilterTypes: []any{&FilterByKeyspace{}}, }, + { + name: "tabletFiltersAndTags", + tabletFilters: []string{"ks1|-80"}, + tabletFilterTags: map[string]string{"test": "true"}, + expectedFilterTypes: []any{&FilterByShard{}, &FilterByTabletTags{}}, + }, + { + name: "keyspacesToWatchAndTags", + tabletFilterTags: map[string]string{"test": "true"}, + keyspacesToWatch: []string{"ks1"}, + expectedFilterTypes: []any{&FilterByKeyspace{}, &FilterByTabletTags{}}, + }, { name: "failKeyspacesToWatchAndFilters", tabletFilters: []string{"ks1|-80"}, @@ -106,6 +120,7 @@ func TestNewVTGateHealthCheckFilters(t *testing.T) { t.Run(testCase.name, func(t *testing.T) { KeyspacesToWatch = testCase.keyspacesToWatch tabletFilters = testCase.tabletFilters + tabletFilterTags = testCase.tabletFilterTags filters, err := NewVTGateHealthCheckFilters() if testCase.expectedError != "" {