Skip to content

Commit

Permalink
tabletserver: Skip wait for DBA grants for external tablets
Browse files Browse the repository at this point in the history
In case of externally managed tablets, we don't want to enforce the DBA
grants check.

Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Nov 28, 2023
1 parent f979961 commit 21179f6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
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

0 comments on commit 21179f6

Please sign in to comment.