Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabletserver: Skip wait for DBA grants for external tablets #14629

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ func NewTabletServer(ctx context.Context, name string, config *tabletenv.TabletC

// WaitForDBAGrants waits for DBA user to have the required privileges to function properly.
func WaitForDBAGrants(config *tabletenv.TabletConfig, waitTime time.Duration) error {
if waitTime == 0 {
// We don't wait for grants if the tablet is externally managed. Permissions
// are then the responsibility of the DBA.
if config.DB.HasGlobalSettings() || waitTime == 0 {
return nil
}
timer := time.NewTimer(waitTime)
Expand Down
28 changes: 27 additions & 1 deletion go/vt/vttablet/tabletserver/tabletserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2706,12 +2706,38 @@ func TestWaitForDBAGrants(t *testing.T) {
cluster.TearDown()
}
},
}, {
name: "Success for externally managed tablet",
waitTime: 300 * time.Millisecond,
errWanted: "",
setupFunc: func(t *testing.T) (*tabletenv.TabletConfig, func()) {
// Create a new mysql but don't give the grants to the vt_dba user at all.
// This should cause a timeout after waiting, since the privileges are never granted.
testUser := "vt_test_dba"
cluster, err := startMySQLAndCreateUser(t, testUser)
require.NoError(t, err)

tc := &tabletenv.TabletConfig{
DB: &dbconfigs.DBConfigs{
Host: "some.unknown.host",
},
}
connParams := cluster.MySQLConnParams()
connParams.Uname = testUser
tc.DB.SetDbParams(connParams, mysql.ConnParams{}, mysql.ConnParams{})
return tc, func() {
cluster.TearDown()
}
},
}, {
name: "Empty timeout",
waitTime: 0,
errWanted: "",
setupFunc: func(t *testing.T) (*tabletenv.TabletConfig, func()) {
return nil, func() {}
tc := &tabletenv.TabletConfig{
DB: &dbconfigs.DBConfigs{},
}
return tc, func() {}
},
},
}
Expand Down
Loading