Skip to content

Commit

Permalink
Fix fetching test route URL
Browse files Browse the repository at this point in the history
  • Loading branch information
sleshchenko committed Aug 29, 2019
1 parent 4af8a1a commit dc390ef
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/controller/che/k8s_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit dc390ef

Please sign in to comment.