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

go/vt/mysqlctl: add postflight_mysqld_start and preflight_mysqld_shutdown hooks #17652

Merged
merged 2 commits into from
Jan 30, 2025
Merged
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
24 changes: 22 additions & 2 deletions go/vt/mysqlctl/mysqld.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,15 @@ func (mysqld *Mysqld) startNoWait(cnf *Mycnf, mysqldArgs ...string) error {
return fmt.Errorf("mysqld_start hook failed: %v", hr.String())
}

// try the postflight mysqld start hook, if any
switch hr := hook.NewHook("postflight_mysqld_start", mysqldArgs).Execute(); hr.ExitStatus {
case hook.HOOK_SUCCESS, hook.HOOK_DOES_NOT_EXIST:
// hook exists and worked, or does not exist, we can keep going
default:
// hook failed, we report error
return fmt.Errorf("postflight_mysqld_start hook failed: %v", hr.String())
}

return nil
}

Expand Down Expand Up @@ -624,10 +633,21 @@ func (mysqld *Mysqld) Shutdown(ctx context.Context, cnf *Mycnf, waitForMysqld bo
return nil
}

// try the mysqld shutdown hook, if any
h := hook.NewSimpleHook("mysqld_shutdown")
// try the preflight mysqld shutdown hook, if any
h := hook.NewSimpleHook("preflight_mysqld_shutdown")
hr := h.ExecuteContext(ctx)
switch hr.ExitStatus {
case hook.HOOK_SUCCESS, hook.HOOK_DOES_NOT_EXIST:
// hook exists and worked, or else does not exist.
default:
// hook failed, we report error
return fmt.Errorf("preflight_mysqld_shutdown hook failed: %v", hr.String())
}

// try the mysqld shutdown hook, if any
h = hook.NewSimpleHook("mysqld_shutdown")
hr = h.ExecuteContext(ctx)
switch hr.ExitStatus {
case hook.HOOK_SUCCESS:
// hook exists and worked, we can keep going
case hook.HOOK_DOES_NOT_EXIST:
Expand Down
Loading