Skip to content

Commit

Permalink
Merge pull request vitessio#9187 from ajm188/no-default-buildinfo-tags
Browse files Browse the repository at this point in the history
Default buildinfo tablet tags to off
  • Loading branch information
ajm188 authored Nov 11, 2021
2 parents b04bca6 + 451103b commit e83b2eb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletmanager/tm_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var (
initShard = flag.String("init_shard", "", "(init parameter) shard to use for this tablet")
initTabletType = flag.String("init_tablet_type", "", "(init parameter) the tablet type to use for this tablet.")
initDbNameOverride = flag.String("init_db_name_override", "", "(init parameter) override the name of the db used by vttablet. Without this flag, the db name defaults to vt_<keyspacename>")
skipBuildInfoTags = flag.String("vttablet_skip_buildinfo_tags", "", "comma-separated list of buildinfo tags to skip from merging with -init_tags. each tag is either an exact match or a regular expression of the form '/regexp/'.")
skipBuildInfoTags = flag.String("vttablet_skip_buildinfo_tags", "/.*/", "comma-separated list of buildinfo tags to skip from merging with -init_tags. each tag is either an exact match or a regular expression of the form '/regexp/'.")
initTags flagutil.StringMapValue

initPopulateMetadata = flag.Bool("init_populate_metadata", false, "(init parameter) populate metadata tables even if restore_from_backup is disabled. If restore_from_backup is enabled, metadata tables are always populated regardless of this flag.")
Expand Down
38 changes: 37 additions & 1 deletion go/vt/vttablet/tabletmanager/tm_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestStartBuildTabletFromInput(t *testing.T) {
Shard: "0",
KeyRange: nil,
Type: topodatapb.TabletType_REPLICA,
Tags: servenv.AppVersion.ToStringMap(),
Tags: map[string]string{},
DbNameOverride: "aa",
}

Expand Down Expand Up @@ -121,6 +121,42 @@ func TestStartBuildTabletFromInput(t *testing.T) {
assert.Contains(t, err.Error(), "invalid init_tablet_type PRIMARY")
}

func TestBuildTabletFromInputWithBuildTags(t *testing.T) {
alias := &topodatapb.TabletAlias{
Cell: "cell",
Uid: 1,
}
port := int32(12)
grpcport := int32(34)

// Hostname should be used as is.
*tabletHostname = "foo"
*initKeyspace = "test_keyspace"
*initShard = "0"
*initTabletType = "replica"
*initDbNameOverride = "aa"
*skipBuildInfoTags = ""
defer func() { *skipBuildInfoTags = "/.*/" }()
wantTablet := &topodatapb.Tablet{
Alias: alias,
Hostname: "foo",
PortMap: map[string]int32{
"vt": port,
"grpc": grpcport,
},
Keyspace: "test_keyspace",
Shard: "0",
KeyRange: nil,
Type: topodatapb.TabletType_REPLICA,
Tags: servenv.AppVersion.ToStringMap(),
DbNameOverride: "aa",
}

gotTablet, err := BuildTabletFromInput(alias, port, grpcport)
require.NoError(t, err)
assert.Equal(t, wantTablet, gotTablet)
}

func TestStartCreateKeyspaceShard(t *testing.T) {
defer func(saved time.Duration) { rebuildKeyspaceRetryInterval = saved }(rebuildKeyspaceRetryInterval)
rebuildKeyspaceRetryInterval = 10 * time.Millisecond
Expand Down

0 comments on commit e83b2eb

Please sign in to comment.