diff --git a/go/vt/vttablet/tabletmanager/tm_init.go b/go/vt/vttablet/tabletmanager/tm_init.go index 42d5e128147..f2223326ed9 100644 --- a/go/vt/vttablet/tabletmanager/tm_init.go +++ b/go/vt/vttablet/tabletmanager/tm_init.go @@ -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_") - 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.") diff --git a/go/vt/vttablet/tabletmanager/tm_init_test.go b/go/vt/vttablet/tabletmanager/tm_init_test.go index 753bcdee27f..74ffea70c37 100644 --- a/go/vt/vttablet/tabletmanager/tm_init_test.go +++ b/go/vt/vttablet/tabletmanager/tm_init_test.go @@ -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", } @@ -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