SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

503 service not found while running on openshift #300

Closed nazisangg closed 6 years ago

nazisangg commented 6 years ago

Hi, I was trying to deploy restHeart to openshift. To adopt our openshift environment, I changed the entry point of configuration(only mongo url and http port) from "get from yaml" to "get from system environment".

**httpPort = Integer.parseInt(System.getenv().getOrDefault(HTTP_PORT_KEY,"8080")); //httpPort = getAsIntegerOrDefault(conf, HTTP_PORT_KEY, DEFAULT_HTTP_PORT);

mongoUri = new MongoClientURI(System.getenv().getOrDefault( MONGO_URI_KEY, DEFAULT_MONGO_URI));**

It works fine from my local. However I got some issue on openshift. The Hal browser will return a 503 Service Unavailable exception.

I tested the mongodb pod on openshift. It should be working properly. The init of application is shown below: image

Expected Behavior

Since the auth and connection is passed. 200 ok should be printed

Current Behavior

image

Context

New to Restheart, need it to be running on openshift.

Environment

The image is running with centos 7, mongodb is on version 3.2. The version of restheart is the latest one from github.

Steps to Reproduce

  1. change the code as above and build a image within centos 7 docker environment
  2. set the url with a format: mongodb://user:password@host/?authSource=databasename and leave others as default
  3. deploy and run

Possible Implementation

mkjsix commented 6 years ago

Why don't you try to build your image starting from the official image instead? The base image is openjdk:8u151-jre-alpine which is based on Alpine Linux and Openjdk. We haven't tested with Centos based images.

However, I made a quick test with image mimacom/centos7-java:openjdk-8 and RESTHeart works just fine.

schermata 2018-07-13 alle 09 09 01

ujibang commented 6 years ago

Hi @nazisangg ,

from the restheart log I see that it is starting and connecting to mongodb. I also see that the http interface is bound to port 8080 and https to 4443.

The screenshot of the HAL browser shows a response body with html, also the response header does not contain X-powered-by: restheart.org: it must be some other process responding.

mkjsix commented 6 years ago

Indeed it should be the case. You should see that in my case the Properties object showed by the HAL Browser contains the "restheart_version": "3.5.0-SNAPSHOT" while in @nazisangg case is empty.

nazisangg commented 6 years ago

Thanks guys. I recently solved the problem. It is ok to use centos in that case. It should be a openshift issue. A possible solution cloud be:

  1. disable Secure route
  2. set the base route path as empty instead of /browser image

It works for me... Although I have no idea why it works....