Define simple healthchecks for simulators 71/58871/1
authorfkrzywka <filip.krzywka@nokia.com>
Mon, 30 Jul 2018 10:55:03 +0000 (12:55 +0200)
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>
Fri, 3 Aug 2018 08:24:25 +0000 (10:24 +0200)
- currently containers are healthy if they have successfully started
their Http servers thus simple endpoint at /healthcheck is sufficient
- to enable docker healthcheck we need to add `curl` to docker images
- http_proxy needs to be provided for docker to be able to build images
behind proxy

Closes ONAP-695

Change-Id: I02f0b8cc2732713b5307dbc34ba604d8185b74fc
Signed-off-by: fkrzywka <filip.krzywka@nokia.com>
Issue-ID: DCAEGEN2-601

.gitlab-ci.yml
hv-collector-dcae-app-simulator/Dockerfile
hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/remote/ApiServer.kt
hv-collector-xnf-simulator/Dockerfile
hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/HttpServer.kt
pom.xml

index 5585f92..a1d94ac 100644 (file)
@@ -8,7 +8,7 @@ stages:
 build:
   stage: build
   script:
-    - mvn -e -T2 -Panalysis clean install
+    - mvn -e -T2 -Panalysis clean install -Ddocker.http_proxy="http://$PROXY_HOST:$PROXY_PORT" -Ddocker.https_proxy="http://$PROXY_HOST:$PROXY_PORT"
   artifacts:
     paths:
       - hv-collector-coverage/target/site/jacoco-aggregate
index 39bd878..55bf645 100644 (file)
@@ -5,6 +5,10 @@ LABEL license.name="The Apache Software License, Version 2.0"
 LABEL license.url="http://www.apache.org/licenses/LICENSE-2.0"
 LABEL maintainer="Nokia Wroclaw ONAP Team"
 
+RUN apt-get update \
+        && apt-get install -y --no-install-recommends curl  \
+        && apt-get clean
+
 WORKDIR /opt/ves-hv-dcae-app-simulator
 ENTRYPOINT ["java", "-cp", "*:", "org.onap.dcae.collectors.veshv.simulators.dcaeapp.MainKt"]
 COPY target/libs/external/* ./
index cb1484b..79f143e 100644 (file)
@@ -93,6 +93,9 @@ class ApiServer(private val consumerFactory: ConsumerFactory,
                                         .block()
                             }
                 }
+                .get("healthcheck") { ctx ->
+                    ctx.response.status(STATUS_OK).send()
+                }
     }
 
     private fun generateEvents(ctx: Context, parameters: List<MessageParameters>):
index 48f9dc5..e48a80e 100644 (file)
@@ -5,8 +5,13 @@ LABEL license.name="The Apache Software License, Version 2.0"
 LABEL license.url="http://www.apache.org/licenses/LICENSE-2.0"
 LABEL maintainer="Nokia Wroclaw ONAP Team"
 
+RUN apt-get update \
+        && apt-get install -y --no-install-recommends curl  \
+        && apt-get clean
+
 WORKDIR /opt/ves-hv-client-simulator
 ENTRYPOINT ["java", "-cp", "*:", "org.onap.dcae.collectors.veshv.simulators.xnf.MainKt"]
 COPY target/libs/external/* ./
 COPY target/libs/internal/* ./
 COPY target/hv-collector-xnf-simulator-*.jar ./
+
index de686bc..e602573 100644 (file)
@@ -66,6 +66,9 @@ internal class HttpServer(private val vesClient: XnfSimulator,
                             .onError { handleException(it, ctx) }
                             .then { sendAcceptedResponse(ctx) }
                 }
+                .get("healthcheck") { ctx ->
+                    ctx.response.status(STATUS_OK).send()
+                }
     }
 
     private fun sendAcceptedResponse(ctx: Context) {
diff --git a/pom.xml b/pom.xml
index ef531bf..27461be 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -78,6 +78,8 @@
         <docker-image.registry>${onap.nexus.dockerregistry.daily}</docker-image.registry>
         <docker-image.namespace>onap</docker-image.namespace>
         <docker-image.name>ves-hv-collector/${project.artifactId}</docker-image.name>
+        <docker.http_proxy> </docker.http_proxy>
+        <docker.https_proxy> </docker.https_proxy>
     </properties>
 
 
                                         <alias>${project.artifactId}</alias>
                                         <name>${docker-image.registry}/${docker-image.namespace}/${docker-image.name}</name>
                                         <build>
+                                            <args>
+                                                <http_proxy>${docker.http_proxy}</http_proxy>
+                                                <https_proxy>${docker.https_proxy}</https_proxy>
+                                            </args>
                                             <dockerFileDir>${project.basedir}</dockerFileDir>
                                         </build>
                                     </image>