mirror of
https://github.com/openshift/installer.git
synced 2026-02-05 15:47:14 +01:00
Removed custom agent wait-for install-complete code. Moved installer WaitForInstallComplete function from cmd/openshift-install/main to cmd/openshift-install/command so that the function can be made public. Modified agent.newWaitForInstallCompleted() to use the common WaitForInstallComplete function. The benefit of moving agent over to the common WaitForInstallComplete function is that the common function has a step to wait for operators to be in a stable state before calling the cluster installation complete.
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/sirupsen/logrus"
|
|
"k8s.io/apimachinery/pkg/util/wait"
|
|
)
|
|
|
|
// WaitForBootstrapComplete Wait for the bootstrap process to complete on
|
|
// cluster installations triggered by the agent installer.
|
|
func WaitForBootstrapComplete(cluster *Cluster) error {
|
|
timeout := 60 * time.Minute
|
|
waitContext, cancel := context.WithTimeout(cluster.Ctx, timeout)
|
|
defer cancel()
|
|
|
|
var lastErrOnExit error
|
|
var lastErrStr string
|
|
wait.Until(func() {
|
|
bootstrap, exitOnErr, err := cluster.IsBootstrapComplete()
|
|
if bootstrap && err == nil {
|
|
logrus.Info("cluster bootstrap is complete")
|
|
cancel()
|
|
}
|
|
|
|
if err != nil {
|
|
if exitOnErr {
|
|
lastErrOnExit = err
|
|
cancel()
|
|
} else {
|
|
if err.Error() != lastErrStr {
|
|
logrus.Info(err)
|
|
lastErrStr = err.Error()
|
|
}
|
|
}
|
|
}
|
|
}, 2*time.Second, waitContext.Done())
|
|
|
|
waitErr := waitContext.Err()
|
|
if waitErr != nil {
|
|
if errors.Is(waitErr, context.Canceled) && lastErrOnExit != nil {
|
|
return errors.Wrap(lastErrOnExit, "bootstrap process returned error")
|
|
}
|
|
if errors.Is(waitErr, context.DeadlineExceeded) {
|
|
return errors.Wrap(waitErr, "bootstrap process timed out")
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|