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 Sep 4, 2019
1 parent 07aa108 commit e5c774f
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 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 All @@ -30,7 +31,6 @@ import (
"k8s.io/client-go/kubernetes"
"net/http"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"time"
)

type k8s struct {
Expand Down Expand Up @@ -221,10 +221,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 @@ -257,23 +256,24 @@ func (cl *k8s) GetDeploymentPod(name string, ns string) (podName string, err err
// There's an easier way which is to read tls secret in default (3.11) or openshift-ingress (4.0) namespace
// which however requires extra privileges for operator service account
func (r *ReconcileChe) GetEndpointTlsCrt(instance *orgv1.CheCluster, url string) (certificate []byte, err error) {
testRoute := &routev1.Route{}
var requestURL string
var testRoute *routev1.Route
if len(url) < 1 {
testRoute = deploy.NewTlsRoute(instance, "test", "test", 8080)
logrus.Infof("Creating a test route %s to extract router crt", testRoute.Name)
if err := r.CreateNewRoute(instance, testRoute); err != nil {
logrus.Errorf("Failed to create test route %s: %s", testRoute.Name, err)
return nil, err
testRoute := r.GetEffectiveRoute(instance, "test")
if testRoute == nil {
testRoute = deploy.NewTlsRoute(instance, "test", "test", 8080)
logrus.Infof("Creating a test route %s to extract router crt", testRoute.Name)
if err := r.CreateNewRoute(instance, testRoute); err != nil {
logrus.Errorf("Failed to create test route %s: %s", testRoute.Name, err)
return nil, err
}
}
// sometimes timing conditions apply, and host isn't available right away

if len(testRoute.Spec.Host) < 1 {
time.Sleep(time.Duration(1) * time.Second)
testRoute := r.GetEffectiveRoute(instance, "test")
requestURL = "https://" + testRoute.Spec.Host
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 e5c774f

Please sign in to comment.