system_update: Perform provisioning in parallel

This commit is contained in:
Tom Wiesing 2022-09-22 18:06:46 +02:00
parent c091761762
commit 72d95f58ea
No known key found for this signature in database
15 changed files with 182 additions and 27 deletions

View file

@ -8,6 +8,7 @@ import (
"sync/atomic"
mysqldriver "github.com/go-sql-driver/mysql"
"github.com/tkw1536/goprogram/stream"
"gorm.io/driver/mysql"
"gorm.io/gorm"
@ -43,7 +44,6 @@ func (sql *SQL) Exec(query string, args ...interface{}) error {
func (sql *SQL) WaitExec() error {
return wait.Wait(func() bool {
err := sql.Exec("select 1;")
// log.Printf("[WaitQuery] %s\n", err) // debug
return err == nil
}, sql.PollInterval, sql.PollContext)
}
@ -90,8 +90,10 @@ func (sql *SQL) QueryTable(silent bool, table string) (*gorm.DB, error) {
// WaitQueryTable waits for a connection to succeed via QueryTable
func (sql *SQL) WaitQueryTable() error {
n := stream.FromDebug()
return wait.Wait(func() bool {
_, err := sql.QueryTable(true, models.InstanceTable)
n.EPrintf("[SQL.WaitQueryTable]: %s\n", err)
return err == nil
}, sql.PollInterval, sql.PollContext)
}

View file

@ -21,10 +21,10 @@ func (sql *SQL) Shell(io stream.IOStream, argv ...string) (int, error) {
// unsafeWaitShell waits for a connection via the database shell to succeed
func (sql *SQL) unsafeWaitShell() error {
n := stream.FromNil()
n := stream.FromDebug()
return wait.Wait(func() bool {
code, err := sql.Shell(n, "-e", "select 1;")
// log.Printf("[unsafeWaitShell] %d %s\n", code, err) // debug
n.EPrintf("[SQL.unsafeWaitShell]: %d %s\n", code, err)
return err == nil && code == 0
}, sql.PollInterval, sql.PollContext)
}