fix: Set Che host url in the CR status when Che server deployment is ready (#1040)
* fix: Set Che host url in the CR status when Che server deployment is ready. Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>pull/1051/head
parent
9034d354fd
commit
c36958d8ea
|
|
@ -1083,7 +1083,13 @@ func TestCheController(t *testing.T) {
|
|||
r := &CheClusterReconciler{client: cl, nonCachedClient: cl, Scheme: &scheme, discoveryClient: dc, tests: true, Log: ctrl.Log.WithName("controllers").WithName("CheCluster")}
|
||||
|
||||
// get CR
|
||||
cheCR := &orgv1.CheCluster{}
|
||||
cheCR := &orgv1.CheCluster{
|
||||
Spec: orgv1.CheClusterSpec{
|
||||
Server: orgv1.CheClusterSpecServer{
|
||||
CheHost: "eclipse.org",
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := cl.Get(context.TODO(), types.NamespacedName{Name: os.Getenv("CHE_FLAVOR"), Namespace: namespace}, cheCR); err != nil {
|
||||
t.Errorf("CR not found")
|
||||
}
|
||||
|
|
@ -1283,6 +1289,15 @@ func TestCheController(t *testing.T) {
|
|||
t.Fatalf("Expecting %s storageClassName, got %s", fakeStorageClassName, *actualStorageClassName)
|
||||
}
|
||||
|
||||
// Get CheCR one more time to get it with newer Che url in the status.
|
||||
r.client.Get(context.TODO(), types.NamespacedName{Name: cheCR.GetName(), Namespace: cheCR.GetNamespace()}, cheCR)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get custom resource Eclipse Che: %s", err.Error())
|
||||
}
|
||||
if cheCR.Status.CheURL != "https://eclipse.org" {
|
||||
t.Fatalf("Expected che host url in the custom resource status: %s, but got %s", "https://eclipse.org", cheCR.Status.CheURL)
|
||||
}
|
||||
|
||||
// check if oAuthClient is deleted after CR is deleted (finalizer logic)
|
||||
// since fake api does not set deletion timestamp, CR is updated in tests rather than deleted
|
||||
logrus.Info("Updating CR with deletion timestamp")
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ func (d *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
|
|||
Env: []corev1.EnvVar{
|
||||
{
|
||||
Name: "CHE_HOST",
|
||||
Value: d.deployContext.CheCluster.Status.CheURL,
|
||||
Value: util.GetCheURL(d.deployContext.CheCluster),
|
||||
},
|
||||
{
|
||||
Name: "KEYCLOAK_URL",
|
||||
|
|
|
|||
|
|
@ -59,11 +59,6 @@ func (s *Server) ExposeCheServiceAndEndpoint() (bool, error) {
|
|||
return false, err
|
||||
}
|
||||
|
||||
done, err = s.UpdateCheURL()
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +95,11 @@ func (s *Server) SyncAll() (bool, error) {
|
|||
return false, err
|
||||
}
|
||||
|
||||
done, err = s.UpdateCheURL()
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
|
||||
done, err = s.UpdateCheVersion()
|
||||
if !done {
|
||||
return false, err
|
||||
|
|
@ -193,13 +193,7 @@ func (s Server) ExposeCheEndpoint() (bool, error) {
|
|||
}
|
||||
|
||||
func (s Server) UpdateCheURL() (bool, error) {
|
||||
var cheUrl string
|
||||
if s.deployContext.CheCluster.Spec.Server.TlsSupport {
|
||||
cheUrl = "https://" + s.deployContext.CheCluster.Spec.Server.CheHost
|
||||
} else {
|
||||
cheUrl = "http://" + s.deployContext.CheCluster.Spec.Server.CheHost
|
||||
}
|
||||
|
||||
var cheUrl = util.GetCheURL(s.deployContext.CheCluster)
|
||||
if s.deployContext.CheCluster.Status.CheURL != cheUrl {
|
||||
s.deployContext.CheCluster.Status.CheURL = cheUrl
|
||||
err := deploy.UpdateCheCRStatus(s.deployContext, s.component+" server URL", cheUrl)
|
||||
|
|
|
|||
|
|
@ -612,3 +612,14 @@ func ClearMetadata(objectMeta *metav1.ObjectMeta) {
|
|||
objectMeta.Finalizers = []string{}
|
||||
objectMeta.ManagedFields = []metav1.ManagedFieldsEntry{}
|
||||
}
|
||||
|
||||
// GetCheURL returns Che url.
|
||||
func GetCheURL(cheCluster *orgv1.CheCluster) string {
|
||||
var cheUrl string
|
||||
if cheCluster.Spec.Server.TlsSupport {
|
||||
cheUrl = "https://" + cheCluster.Spec.Server.CheHost
|
||||
} else {
|
||||
cheUrl = "http://" + cheCluster.Spec.Server.CheHost
|
||||
}
|
||||
return cheUrl
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue