@@ -2,8 +2,10 @@ package agent
22
33import (
44 "context"
5+ "net"
56 "os"
67 "path/filepath"
8+ "strconv"
79 "time"
810
911 "github.com/go-openapi/strfmt"
@@ -12,6 +14,7 @@ import (
1214
1315 "github.com/openshift/assisted-service/client/installer"
1416 "github.com/openshift/assisted-service/models"
17+ "github.com/openshift/installer/pkg/gather/ssh"
1518)
1619
1720// Cluster is a struct designed to help interact with the cluster that is
@@ -56,6 +59,7 @@ type clusterInstallStatusHistory struct {
5659 ClusterInstallComplete bool
5760 NotReadyTime time.Time
5861 ValidationResults * validationResults
62+ ClusterInitTime time.Time
5963}
6064
6165// NewCluster initializes a Cluster object
@@ -94,6 +98,7 @@ func NewCluster(ctx context.Context, assetDir string) (*Cluster, error) {
9498 ClusterConsoleRouteCreated : false ,
9599 ClusterConsoleRouteURLCreated : false ,
96100 ClusterInstallComplete : false ,
101+ ClusterInitTime : time .Now (),
97102 }
98103
99104 cvalidationresults := & validationResults {
@@ -136,7 +141,14 @@ func (czero *Cluster) IsBootstrapComplete() (bool, bool, error) {
136141 logrus .Trace ("Current API Status: Agent Rest API: down, Bootstrap Kube API: down" )
137142 if ! czero .installHistory .RestAPISeen && ! czero .installHistory .ClusterKubeAPISeen {
138143 logrus .Debug ("Agent Rest API never initialized. Bootstrap Kube API never initialized" )
139- logrus .Info ("Waiting for cluster install to initialize. Sleeping for 30 seconds" )
144+ elapsedSinceInit := time .Since (czero .installHistory .ClusterInitTime )
145+ // After allowing time for the interface to come up, check if Node0 can be accessed via ssh
146+ if elapsedSinceInit > 2 * time .Minute && ! czero .CanSSHToNodeZero () {
147+ logrus .Info ("Cannot access Rendezvous Host. There may be a network configuration problem, check console for additional info" )
148+ } else {
149+ logrus .Info ("Waiting for cluster install to initialize. Sleeping for 30 seconds" )
150+ }
151+
140152 time .Sleep (30 * time .Second )
141153 return false , false , nil
142154 }
@@ -425,6 +437,18 @@ func (czero *Cluster) PrintInstallStatus(cluster *models.Cluster) error {
425437 return nil
426438}
427439
440+ // CanSSHToNodeZero Checks if ssh to NodeZero succeeds.
441+ func (czero * Cluster ) CanSSHToNodeZero () bool {
442+ ip := czero .API .Rest .NodeZeroIP
443+ port := 22
444+
445+ _ , err := ssh .NewClient ("core" , net .JoinHostPort (ip , strconv .Itoa (port )), czero .API .Rest .NodeSSHKey )
446+ if err != nil {
447+ logrus .Debugf ("Failed to connect to the Rendezvous Host: %s" , err )
448+ }
449+ return err == nil
450+ }
451+
428452// Human friendly install status strings mapped to the Agent Rest API cluster statuses
429453func humanFriendlyClusterInstallStatus (status string ) string {
430454 clusterStoppedInstallingStates := map [string ]string {
0 commit comments