diff --git a/go/vt/discovery/healthcheck.go b/go/vt/discovery/healthcheck.go index bb8bd6499fb..f88b8e554f4 100644 --- a/go/vt/discovery/healthcheck.go +++ b/go/vt/discovery/healthcheck.go @@ -67,29 +67,28 @@ var ( TabletURLTemplateString = flag.String("tablet_url_template", "http://{{.GetTabletHostPort}}", "format string describing debug tablet url formatting. See the Go code for getTabletDebugURL() how to customize this.") tabletURLTemplate *template.Template - //TODO(deepthi): change these vars back to unexported when discoveryGateway is removed - // AllowedTabletTypes is the list of allowed tablet types. e.g. {PRIMARY, REPLICA} AllowedTabletTypes []topodata.TabletType - // TabletFilters are the keyspace|shard or keyrange filters to apply to the full set of tablets - TabletFilters flagutil.StringListValue // KeyspacesToWatch - if provided this specifies which keyspaces should be // visible to the healthcheck. By default the healthcheck will watch all keyspaces. KeyspacesToWatch flagutil.StringListValue - // RefreshInterval is the interval at which healthcheck refreshes its list of tablets from topo - RefreshInterval = flag.Duration("tablet_refresh_interval", 1*time.Minute, "tablet refresh interval") - // RefreshKnownTablets tells us whether to process all tablets or only new tablets - RefreshKnownTablets = flag.Bool("tablet_refresh_known_tablets", true, "tablet refresh reloads the tablet address/port map from topo in case it changes") - // TopoReadConcurrency tells us how many topo reads are allowed in parallel - TopoReadConcurrency = flag.Int("topo_read_concurrency", 32, "concurrent topo reads") + + // tabletFilters are the keyspace|shard or keyrange filters to apply to the full set of tablets + tabletFilters flagutil.StringListValue + // refreshInterval is the interval at which healthcheck refreshes its list of tablets from topo + refreshInterval = flag.Duration("tablet_refresh_interval", 1*time.Minute, "tablet refresh interval") + // refreshKnownTablets tells us whether to process all tablets or only new tablets + refreshKnownTablets = flag.Bool("tablet_refresh_known_tablets", true, "tablet refresh reloads the tablet address/port map from topo in case it changes") + // topoReadConcurrency tells us how many topo reads are allowed in parallel + topoReadConcurrency = flag.Int("topo_read_concurrency", 32, "concurrent topo reads") ) // See the documentation for NewHealthCheck below for an explanation of these parameters. const ( - DefaultHealthCheckRetryDelay = 5 * time.Second - DefaultHealthCheckTimeout = 1 * time.Minute + defaultHealthCheckRetryDelay = 5 * time.Second + defaultHealthCheckTimeout = 1 * time.Minute - // DefaultTopoReadConcurrency is used as the default value for the TopoReadConcurrency parameter of a TopologyWatcher. + // DefaultTopoReadConcurrency is used as the default value for the topoReadConcurrency parameter of a TopologyWatcher. DefaultTopoReadConcurrency int = 5 // DefaultTopologyWatcherRefreshInterval is used as the default value for // the refresh interval of a topology watcher. @@ -141,7 +140,7 @@ func ParseTabletURLTemplateFromFlag() { func init() { // Flags are not parsed at this point and the default value of the flag (just the hostname) will be used. ParseTabletURLTemplateFromFlag() - flag.Var(&TabletFilters, "tablet_filters", "Specifies a comma-separated list of 'keyspace|shard_name or keyrange' values to filter the tablets to watch") + flag.Var(&tabletFilters, "tablet_filters", "Specifies a comma-separated list of 'keyspace|shard_name or keyrange' values to filter the tablets to watch") topoproto.TabletTypeListVar(&AllowedTabletTypes, "allowed_tablet_types", "Specifies the tablet types this vtgate is allowed to route queries to") flag.Var(&KeyspacesToWatch, "keyspaces_to_watch", "Specifies which keyspaces this vtgate should have access to while routing queries or accessing the vschema") } @@ -283,12 +282,12 @@ func NewHealthCheck(ctx context.Context, retryDelay, healthCheckTimeout time.Dur if c == "" { continue } - if len(TabletFilters) > 0 { + if len(tabletFilters) > 0 { if len(KeyspacesToWatch) > 0 { log.Exitf("Only one of -keyspaces_to_watch and -tablet_filters may be specified at a time") } - fbs, err := NewFilterByShard(TabletFilters) + fbs, err := NewFilterByShard(tabletFilters) if err != nil { log.Exitf("Cannot parse tablet_filters parameter: %v", err) } @@ -296,7 +295,7 @@ func NewHealthCheck(ctx context.Context, retryDelay, healthCheckTimeout time.Dur } else if len(KeyspacesToWatch) > 0 { filter = NewFilterByKeyspace(KeyspacesToWatch) } - topoWatchers = append(topoWatchers, NewCellTabletsWatcher(ctx, topoServer, hc, filter, c, *RefreshInterval, *RefreshKnownTablets, *TopoReadConcurrency)) + topoWatchers = append(topoWatchers, NewCellTabletsWatcher(ctx, topoServer, hc, filter, c, *refreshInterval, *refreshKnownTablets, *topoReadConcurrency)) } hc.topoWatchers = topoWatchers diff --git a/go/vt/discovery/legacy_healthcheck.go b/go/vt/discovery/legacy_healthcheck.go index 0f97fa3642a..265c2829057 100644 --- a/go/vt/discovery/legacy_healthcheck.go +++ b/go/vt/discovery/legacy_healthcheck.go @@ -372,7 +372,7 @@ type legacyTabletHealth struct { // NewLegacyDefaultHealthCheck creates a new LegacyHealthCheck object with a default configuration. func NewLegacyDefaultHealthCheck() LegacyHealthCheck { - return NewLegacyHealthCheck(DefaultHealthCheckRetryDelay, DefaultHealthCheckTimeout) + return NewLegacyHealthCheck(defaultHealthCheckRetryDelay, defaultHealthCheckTimeout) } // NewLegacyHealthCheck creates a new LegacyHealthCheck object. diff --git a/go/vt/discovery/legacy_topology_watcher.go b/go/vt/discovery/legacy_topology_watcher.go index cbee6b3b94e..194396df0c1 100644 --- a/go/vt/discovery/legacy_topology_watcher.go +++ b/go/vt/discovery/legacy_topology_watcher.go @@ -55,7 +55,7 @@ func NewLegacyCellTabletsWatcher(ctx context.Context, topoServer *topo.Server, t // NewLegacyShardReplicationWatcher returns a LegacyTopologyWatcher that // monitors the tablets in a cell/keyspace/shard, and starts refreshing. func NewLegacyShardReplicationWatcher(ctx context.Context, topoServer *topo.Server, tr LegacyTabletRecorder, cell, keyspace, shard string, refreshInterval time.Duration, topoReadConcurrency int) *LegacyTopologyWatcher { - return NewLegacyTopologyWatcher(ctx, topoServer, tr, cell, refreshInterval, true /* RefreshKnownTablets */, topoReadConcurrency, func(tw *LegacyTopologyWatcher) ([]*topodatapb.TabletAlias, error) { + return NewLegacyTopologyWatcher(ctx, topoServer, tr, cell, refreshInterval, true /* refreshKnownTablets */, topoReadConcurrency, func(tw *LegacyTopologyWatcher) ([]*topodatapb.TabletAlias, error) { sri, err := tw.topoServer.GetShardReplication(ctx, tw.cell, keyspace, shard) switch { case err == nil: diff --git a/go/vt/discovery/legacy_topology_watcher_test.go b/go/vt/discovery/legacy_topology_watcher_test.go index b828289b1bd..ae533fda5aa 100644 --- a/go/vt/discovery/legacy_topology_watcher_test.go +++ b/go/vt/discovery/legacy_topology_watcher_test.go @@ -138,7 +138,7 @@ func checkLegacyWatcher(t *testing.T, cellTablets, refreshKnownTablets bool) { } tw.loadTablets() - // If RefreshKnownTablets is disabled, only the new tablet is read + // If refreshKnownTablets is disabled, only the new tablet is read // from the topo if refreshKnownTablets { counts = checkLegacyOpCounts(t, tw, counts, map[string]int64{"ListTablets": 1, "GetTablet": 2, "AddTablet": 1}) @@ -154,7 +154,7 @@ func checkLegacyWatcher(t *testing.T, cellTablets, refreshKnownTablets bool) { t.Errorf("fhc.GetAllTablets() = %+v; want %+v", allTablets, tablet2) } - // Load the tablets again to show that when RefreshKnownTablets is disabled, + // Load the tablets again to show that when refreshKnownTablets is disabled, // only the list is read from the topo and the checksum doesn't change tw.loadTablets() if refreshKnownTablets { @@ -167,7 +167,7 @@ func checkLegacyWatcher(t *testing.T, cellTablets, refreshKnownTablets bool) { // same tablet, different port, should update (previous // one should go away, new one be added) // - // if RefreshKnownTablets is disabled, this case is *not* + // if refreshKnownTablets is disabled, this case is *not* // detected and the tablet remains in the topo using the // old key origTablet := proto.Clone(tablet).(*topodatapb.Tablet) @@ -209,7 +209,7 @@ func checkLegacyWatcher(t *testing.T, cellTablets, refreshKnownTablets bool) { // trigger a ReplaceTablet in loadTablets because the uid does not // match. // - // This case *is* detected even if RefreshKnownTablets is false + // This case *is* detected even if refreshKnownTablets is false // because the delete tablet / create tablet sequence causes the // list of tablets to change and therefore the change is detected. if err := ts.DeleteTablet(context.Background(), tablet2.Alias); err != nil { diff --git a/go/vt/discovery/topology_watcher_test.go b/go/vt/discovery/topology_watcher_test.go index 1ea6bfe2418..7ba29b4eac6 100644 --- a/go/vt/discovery/topology_watcher_test.go +++ b/go/vt/discovery/topology_watcher_test.go @@ -169,7 +169,7 @@ func checkWatcher(t *testing.T, refreshKnownTablets bool) { } tw.loadTablets() - // If RefreshKnownTablets is disabled, only the new tablet is read + // If refreshKnownTablets is disabled, only the new tablet is read // from the topo if refreshKnownTablets { counts = checkOpCounts(t, counts, map[string]int64{"ListTablets": 1, "GetTablet": 2, "AddTablet": 1}) @@ -185,7 +185,7 @@ func checkWatcher(t *testing.T, refreshKnownTablets bool) { t.Errorf("fhc.GetAllTablets() = %+v; want %+v", allTablets, tablet2) } - // Load the tablets again to show that when RefreshKnownTablets is disabled, + // Load the tablets again to show that when refreshKnownTablets is disabled, // only the list is read from the topo and the checksum doesn't change tw.loadTablets() if refreshKnownTablets { @@ -198,7 +198,7 @@ func checkWatcher(t *testing.T, refreshKnownTablets bool) { // same tablet, different port, should update (previous // one should go away, new one be added) // - // if RefreshKnownTablets is disabled, this case is *not* + // if refreshKnownTablets is disabled, this case is *not* // detected and the tablet remains in the topo using the // old key origTablet := proto.Clone(tablet).(*topodatapb.Tablet)