Skip to content

Commit b91f8c1

Browse files
authored
Add healthchecks (#383)
* added additional configuration variable for director EXTRA_HOSTS_SUFFIX if there are extra hosts defined for the director it will pass them to the services * added generic python based curl for docker * added healthcheck for director, webserver, modeling webserver, jupyter notebook and paraviewweb * some notes for hybrid swarm * pylint
1 parent 4acdc2e commit b91f8c1

File tree

8 files changed

+37
-7
lines changed

8 files changed

+37
-7
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os
2+
import sys
3+
4+
try:
5+
from urllib.request import urlopen
6+
except ImportError:
7+
from urllib2 import urlopen
8+
9+
print(0 if urlopen("{host}{baseurl}".format(host=sys.argv[1], baseurl=os.environ.get("SIMCORE_NODE_BASEPATH", "")) ).getcode() == 200 else 1)

services/director/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ ENV REGISTRY_URL = ''
2222
ENV PUBLISHED_HOST_NAME=''
2323
ENV EXTRA_HOSTS_SUFFIX = 'undefined'
2424

25+
# ----------------------------------------------------------------
26+
COPY --chown=scu:scu scripts/docker/healthcheck_curl_host.py /healthcheck/healthcheck_curl_host.py
27+
# will start to run after interval every interval. fails after timeout. fail do not count if during start-period. will do # retries
28+
HEALTHCHECK --interval=10s --timeout=30s --start-period=1s --retries=3 CMD [ "python3", "/healthcheck/healthcheck_curl_host.py", "http://localhost:8001/v0/" ]
29+
2530
WORKDIR /home/scu
2631

2732
# -------------------------- Build stage -------------------

services/dy-3dvis/simcoreparaviewweb/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/py
4040
COPY --from=visualizer /home/node/visualizer/dist /opt/paraview/install/share/paraview-5.5/web/visualizer/www
4141
WORKDIR /home/root
4242
# ----------------------------------------------------------------
43+
COPY scripts/docker/healthcheck_curl_host.py /healthcheck/healthcheck_curl_host.py
44+
# will start to run after interval every interval. fails after timeout. fail do not count if during start-period. will do # retries
45+
HEALTHCHECK --interval=10s --timeout=30s --start-period=1s --retries=3 CMD [ "python3", "/healthcheck/healthcheck_curl_host.py", "http://localhost:80/visualizer" ]
46+
4347
# set up oSparc env variables
4448
ENV SIMCORE_NODE_UUID="-1" \
4549
SIMCORE_USER_ID="-1" \

services/dy-jupyter/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ ENV SIMCORE_NODE_UUID="-1" \
3131
POSTGRES_PASSWORD="-1" \
3232
POSTGRES_DB="-1"
3333
# ----------------------------------------------------------------
34+
COPY --chown=jovyan:users scripts/docker/healthcheck_curl_host.py /healthcheck/healthcheck_curl_host.py
35+
# will start to run after interval every interval. fails after timeout. fail do not count if during start-period. will do # retries
36+
HEALTHCHECK --interval=10s --timeout=30s --start-period=1s --retries=3 CMD [ "python3", "/healthcheck/healthcheck_curl_host.py", "http://localhost:8888" ]
3437
# configure notebook
3538
RUN pip install --upgrade pip && \
3639
pip install jupyter_contrib_nbextensions && \

services/dy-modeling/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
# Dynamic modeling service using a [qooxdoo](http://qooxdoo.org/) + [three.js](https://threejs.org/) client and a [node.js] (https://nodejs.org/) server
1+
# Dynamic modeling service using a [qooxdoo](http://qooxdoo.org/) + [three.js](https://threejs.org/) client and a [node.js] (https://nodejs.org/) server
2+
3+
## Hybrid swarm (Windows tips)
4+
### multiple network adapters
5+
Check the Hyper-V manager in the switch manager. When joining the swarm docker creates a virtual network named as the network ID. Check that this
6+
network actually uses the right adapter.

services/dy-modeling/server/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ ARG s4l_port_mod="9096"
1616
ENV CS_S4L_HOSTNAME $s4l_ip
1717
ENV CS_S4L_PORT_APP $s4l_port_app
1818
ENV CS_S4L_PORT_MOD $s4l_port_mod
19-
19+
# ----------------------------------------------------------------
20+
COPY scripts/docker/healthcheck_curl_host.py /healthcheck/healthcheck_curl_host.py
21+
# will start to run after interval every interval. fails after timeout. fail do not count if during start-period. will do # retries
22+
HEALTHCHECK --interval=10s --timeout=30s --start-period=1s --retries=3 CMD [ "python", "/healthcheck/healthcheck_curl_host.py", "http://localhost:9090" ]
2023
# + /home/node/ json files
2124
# + source-output/ client source files
2225
# + source/ server source files

services/web/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ ENV IS_CONTAINER_CONTEXT Yes
2323

2424
EXPOSE 8080
2525

26+
# ----------------------------------------------------------------
27+
COPY --chown=scu:scu scripts/docker/healthcheck_curl_host.py /healthcheck/healthcheck_curl_host.py
28+
# will start to run after interval every interval. fails after timeout. fail do not count if during start-period. will do # retries
29+
HEALTHCHECK --interval=10s --timeout=30s --start-period=1s --retries=3 CMD [ "python", "/healthcheck/healthcheck_curl_host.py", "http://localhost:8080" ]
30+
2631
# -------------------------- Build stage -------------------
2732
#
2833
# + /home/scu/ $HOME

services/web/server/src/simcore_service_webserver/director/handlers.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ def _resolve_url(request: web.Request) -> URL:
3434

3535
@login_required
3636
async def services_get(request: web.Request) -> web.Response:
37-
params, query, body = await extract_and_validate(request)
38-
39-
assert not params
40-
assert query
41-
assert not body
37+
_, _, _ = await extract_and_validate(request)
4238

4339
url = _resolve_url(request)
4440

0 commit comments

Comments
 (0)