diff --git a/pkg/controller/che/k8s_helpers.go b/pkg/controller/che/k8s_helpers.go index 9265ed958d..ed2a6084ff 100644 --- a/pkg/controller/che/k8s_helpers.go +++ b/pkg/controller/che/k8s_helpers.go @@ -16,6 +16,7 @@ import ( "context" "crypto/tls" "encoding/pem" + "errors" orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1" "github.com/eclipse/che-operator/pkg/deploy" "github.com/eclipse/che-operator/pkg/util" @@ -221,10 +222,9 @@ func (cl *k8s) GetEvents(deploymentName string, ns string) (list *corev1.EventLi } // GetLogs prints stderr or stdout from a selected pod. Log size is capped at 60000 bytes -func (cl *k8s) GetPodLogs(podName string, ns string) () { +func (cl *k8s) GetPodLogs(podName string, ns string) { var limitBytes int64 = 60000 - req := cl.clientset.CoreV1().Pods(ns).GetLogs(podName, &corev1.PodLogOptions{LimitBytes: &limitBytes}, - ) + req := cl.clientset.CoreV1().Pods(ns).GetLogs(podName, &corev1.PodLogOptions{LimitBytes: &limitBytes}) readCloser, err := req.Stream() if err != nil { logrus.Errorf("Pod error log: %v", err) @@ -267,13 +267,16 @@ func (r *ReconcileChe) GetEndpointTlsCrt(instance *orgv1.CheCluster, url string) return nil, err } // sometimes timing conditions apply, and host isn't available right away - if len(testRoute.Spec.Host) < 1 { + for i := 0; i < 10 && len(testRoute.Spec.Host) < 1; i++ { time.Sleep(time.Duration(1) * time.Second) - testRoute := r.GetEffectiveRoute(instance, "test") - requestURL = "https://" + testRoute.Spec.Host + testRoute = r.GetEffectiveRoute(instance, "test") + } + + if len(testRoute.Spec.Host) < 1 { + return nil, errors.New("Unable to get test route host for fetching certificate") } - requestURL = "https://" + testRoute.Spec.Host + requestURL = "https://" + testRoute.Spec.Host } else { requestURL = url }