Skip to content

Commit 773a2b0

Browse files
committed
cmd/openshift-install/create: Log a more optimistic error for Progressing
And point at 'wait-for install-complete'. This gives a better experience for users that we time out because they're installing over a slow network or something. We might want to fail fast if we see a Failing, instead of waiting for the full timeout. But I'm leaving that alone for now; we can always come back to it in follow-up work.
1 parent 3585a93 commit 773a2b0

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

cmd/openshift-install/create.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/x509"
66
"fmt"
77
"io/ioutil"
8+
"os"
89
"path/filepath"
910
"strings"
1011
"time"
@@ -317,17 +318,18 @@ func waitForBootstrapConfigMap(ctx context.Context, client *kubernetes.Clientset
317318

318319
// waitForInitializedCluster watches the ClusterVersion waiting for confirmation
319320
// that the cluster has been initialized.
320-
func waitForInitializedCluster(ctx context.Context, config *rest.Config) error {
321+
func waitForInitializedCluster(ctx context.Context, config *rest.Config) (configv1.ClusterStatusConditionType, error) {
322+
failing := configv1.ClusterStatusConditionType("Failing")
323+
status := failing
321324
timeout := 30 * time.Minute
322325
logrus.Infof("Waiting up to %v for the cluster at %s to initialize...", timeout, config.Host)
323326
cc, err := configclient.NewForConfig(config)
324327
if err != nil {
325-
return errors.Wrap(err, "failed to create a config client")
328+
return status, errors.Wrap(err, "failed to create a config client")
326329
}
327330
clusterVersionContext, cancel := context.WithTimeout(ctx, timeout)
328331
defer cancel()
329332

330-
failing := configv1.ClusterStatusConditionType("Failing")
331333
var lastError string
332334
_, err = clientwatch.UntilWithSync(
333335
clusterVersionContext,
@@ -343,11 +345,14 @@ func waitForInitializedCluster(ctx context.Context, config *rest.Config) error {
343345
return false, nil
344346
}
345347
if cov1helpers.IsStatusConditionTrue(cv.Status.Conditions, configv1.OperatorAvailable) {
348+
status = configv1.OperatorAvailable
346349
return true, nil
347350
}
348351
if cov1helpers.IsStatusConditionTrue(cv.Status.Conditions, failing) {
352+
status = failing
349353
lastError = cov1helpers.FindStatusCondition(cv.Status.Conditions, failing).Message
350354
} else if cov1helpers.IsStatusConditionTrue(cv.Status.Conditions, configv1.OperatorProgressing) {
355+
status = configv1.OperatorProgressing
351356
lastError = cov1helpers.FindStatusCondition(cv.Status.Conditions, configv1.OperatorProgressing).Message
352357
}
353358
logrus.Debugf("Still waiting for the cluster to initialize: %s", lastError)
@@ -360,14 +365,17 @@ func waitForInitializedCluster(ctx context.Context, config *rest.Config) error {
360365

361366
if err == nil {
362367
logrus.Debug("Cluster is initialized")
363-
return nil
368+
return status, nil
364369
}
365370

366371
if lastError != "" {
367-
return errors.Wrapf(err, "failed to initialize the cluster: %s", lastError)
372+
if status == configv1.OperatorProgressing {
373+
return status, errors.Wrapf(err, "the cluster is still initializing: %s", lastError)
374+
}
375+
return status, errors.Wrapf(err, "failed to initialize the cluster: %s", lastError)
368376
}
369377

370-
return errors.Wrap(err, "failed to initialize the cluster")
378+
return status, errors.Wrap(err, "failed to initialize the cluster")
371379
}
372380

373381
// waitForConsole returns the console URL from the route 'console' in namespace openshift-console
@@ -431,7 +439,7 @@ func waitForConsole(ctx context.Context, config *rest.Config, directory string,
431439
}
432440

433441
// logComplete prints info upon completion
434-
func logComplete(config *rest.Config, directory, consoleURL string, complete bool) error {
442+
func logComplete(config *rest.Config, directory string, clusterStatus configv1.ClusterStatusConditionType, consoleURL string, complete bool) error {
435443
absDir, err := filepath.Abs(directory)
436444
if err != nil {
437445
return err
@@ -444,8 +452,10 @@ func logComplete(config *rest.Config, directory, consoleURL string, complete boo
444452
}
445453
if complete {
446454
logrus.Info("Install complete!")
455+
logrus.Infof("To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=%s'", kubeconfig)
456+
} else if clusterStatus == configv1.OperatorProgressing {
457+
logrus.Infof("To give the cluster more time to initialize, you can run '%s wait-for install-complete'.", os.Args[0])
447458
}
448-
logrus.Infof("To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=%s'", kubeconfig)
449459
if consoleURL != "" {
450460
logrus.Infof("Access the OpenShift web-console here: %s", consoleURL)
451461
logrus.Infof("Login to the console with user: kubeadmin, password: %s", pw)
@@ -455,7 +465,7 @@ func logComplete(config *rest.Config, directory, consoleURL string, complete boo
455465

456466
func waitForInstallComplete(ctx context.Context, config *rest.Config, directory string) error {
457467
errs := []error{}
458-
err := waitForInitializedCluster(ctx, config)
468+
clusterStatus, err := waitForInitializedCluster(ctx, config)
459469
if err != nil {
460470
errs = append(errs, err)
461471
}
@@ -469,7 +479,7 @@ func waitForInstallComplete(ctx context.Context, config *rest.Config, directory
469479
errs = append(errs, err)
470480
}
471481

472-
if err = logComplete(config, rootOpts.dir, consoleURL, utilerrors.NewAggregate(errs) == nil); err != nil {
482+
if err = logComplete(config, rootOpts.dir, clusterStatus, consoleURL, utilerrors.NewAggregate(errs) == nil); err != nil {
473483
errs = append(errs, err)
474484
}
475485

0 commit comments

Comments
 (0)