-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 fixing randomly failing [sys] deploy simcore #2430
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8968fa8
migration service starts an http server
3d58640
added wait-for script
6b3f091
exposed service on all ports
0c80cad
added wait-for in docker files
7ce9c33
Merge remote-tracking branch 'upstream/master' into fix-boot-order
18c6b0e
sidecars were not connected to the network
dd515e6
storage requires migration
2a3cdce
Merge remote-tracking branch 'upstream/master' into fix-boot-order
f914357
adding more debugging info for test_core_service_running when fialing
165d832
adding more debug logging
f8719f6
removing failing command
aae2534
fix test causing CI to fail
5322703
fixes broken integration tests
76798da
removed not neededmmigration service
55f5f10
trying to fix failing tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# wait-for script | ||
|
||
Used by almost all the services. Update it from the repo's official [release page](https://github.com/eficode/wait-for/releases). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
#!/bin/sh | ||
|
||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2017 Eficode Oy | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
set -- "$@" -- "$TIMEOUT" "$QUIET" "$PROTOCOL" "$HOST" "$PORT" "$result" | ||
TIMEOUT=15 | ||
QUIET=0 | ||
# The protocol to make the request with, either "tcp" or "http" | ||
PROTOCOL="tcp" | ||
|
||
echoerr() { | ||
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi | ||
} | ||
|
||
usage() { | ||
exitcode="$1" | ||
cat << USAGE >&2 | ||
Usage: | ||
$0 host:port|url [-t timeout] [-- command args] | ||
-q | --quiet Do not output any status messages | ||
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout | ||
-- COMMAND ARGS Execute command with args after the test finishes | ||
USAGE | ||
exit "$exitcode" | ||
} | ||
|
||
wait_for() { | ||
case "$PROTOCOL" in | ||
tcp) | ||
if ! command -v nc >/dev/null; then | ||
echoerr 'nc command is missing!' | ||
exit 1 | ||
fi | ||
;; | ||
wget) | ||
if ! command -v wget >/dev/null; then | ||
echoerr 'nc command is missing!' | ||
exit 1 | ||
fi | ||
;; | ||
esac | ||
|
||
while :; do | ||
case "$PROTOCOL" in | ||
tcp) | ||
nc -w 1 -z "$HOST" "$PORT" > /dev/null 2>&1 | ||
;; | ||
http) | ||
wget --timeout=1 -q "$HOST" -O /dev/null > /dev/null 2>&1 | ||
;; | ||
*) | ||
echoerr "Unknown protocol '$PROTOCOL'" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
result=$? | ||
|
||
if [ $result -eq 0 ] ; then | ||
if [ $# -gt 7 ] ; then | ||
for result in $(seq $(($# - 7))); do | ||
result=$1 | ||
shift | ||
set -- "$@" "$result" | ||
done | ||
|
||
TIMEOUT=$2 QUIET=$3 PROTOCOL=$4 HOST=$5 PORT=$6 result=$7 | ||
shift 7 | ||
exec "$@" | ||
fi | ||
exit 0 | ||
fi | ||
|
||
if [ "$TIMEOUT" -le 0 ]; then | ||
break | ||
fi | ||
TIMEOUT=$((TIMEOUT - 1)) | ||
|
||
sleep 1 | ||
done | ||
echo "Operation timed out" >&2 | ||
exit 1 | ||
} | ||
|
||
while :; do | ||
case "$1" in | ||
http://*|https://*) | ||
HOST="$1" | ||
PROTOCOL="http" | ||
shift 1 | ||
;; | ||
*:* ) | ||
HOST=$(printf "%s\n" "$1"| cut -d : -f 1) | ||
PORT=$(printf "%s\n" "$1"| cut -d : -f 2) | ||
shift 1 | ||
;; | ||
-q | --quiet) | ||
QUIET=1 | ||
shift 1 | ||
;; | ||
-q-*) | ||
QUIET=0 | ||
echoerr "Unknown option: $1" | ||
usage 1 | ||
;; | ||
-q*) | ||
QUIET=1 | ||
result=$1 | ||
shift 1 | ||
set -- -"${result#-q}" "$@" | ||
;; | ||
-t | --timeout) | ||
TIMEOUT="$2" | ||
shift 2 | ||
;; | ||
-t*) | ||
TIMEOUT="${1#-t}" | ||
shift 1 | ||
;; | ||
--timeout=*) | ||
TIMEOUT="${1#*=}" | ||
shift 1 | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
--help) | ||
usage 0 | ||
;; | ||
-*) | ||
QUIET=0 | ||
echoerr "Unknown option: $1" | ||
usage 1 | ||
;; | ||
*) | ||
QUIET=0 | ||
echoerr "Unknown argument: $1" | ||
usage 1 | ||
;; | ||
esac | ||
done | ||
|
||
if ! [ "$TIMEOUT" -ge 0 ] 2>/dev/null; then | ||
echoerr "Error: invalid timeout '$TIMEOUT'" | ||
usage 3 | ||
fi | ||
|
||
case "$PROTOCOL" in | ||
tcp) | ||
if [ "$HOST" = "" ] || [ "$PORT" = "" ]; then | ||
echoerr "Error: you need to provide a host and port to test." | ||
usage 2 | ||
fi | ||
;; | ||
http) | ||
if [ "$HOST" = "" ]; then | ||
echoerr "Error: you need to provide a host to test." | ||
usage 2 | ||
fi | ||
;; | ||
esac | ||
|
||
wait_for "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,33 +11,33 @@ FROM python:${PYTHON_VERSION}-slim-buster as base | |
LABEL maintainer=pcrespov | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y gosu; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
# verify that the binary works | ||
gosu nobody true | ||
apt-get update; \ | ||
apt-get install -y gosu; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
# verify that the binary works | ||
gosu nobody true | ||
|
||
# simcore-user uid=8004(scu) gid=8004(scu) groups=8004(scu) | ||
ENV SC_USER_ID=8004 \ | ||
SC_USER_NAME=scu \ | ||
SC_BUILD_TARGET=base \ | ||
SC_BOOT_MODE=default | ||
SC_USER_NAME=scu \ | ||
SC_BUILD_TARGET=base \ | ||
SC_BOOT_MODE=default | ||
|
||
RUN adduser \ | ||
--uid ${SC_USER_ID} \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--shell /bin/sh \ | ||
--home /home/${SC_USER_NAME} \ | ||
${SC_USER_NAME} | ||
--uid ${SC_USER_ID} \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--shell /bin/sh \ | ||
--home /home/${SC_USER_NAME} \ | ||
${SC_USER_NAME} | ||
|
||
|
||
# Sets utf-8 encoding for Python et al | ||
ENV LANG=C.UTF-8 | ||
|
||
# Turns off writing .pyc files; superfluous on an ephemeral container. | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
VIRTUAL_ENV=/home/scu/.venv | ||
VIRTUAL_ENV=/home/scu/.venv | ||
|
||
# Ensures that the python and pip executables used in the image will be | ||
# those from our virtualenv. | ||
|
@@ -56,20 +56,21 @@ FROM base as build | |
ENV SC_BUILD_TARGET=build | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
wget \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# NOTE: python virtualenv is used here such that installed | ||
# packages may be moved to production image easily by copying the venv | ||
RUN python -m venv "${VIRTUAL_ENV}" | ||
|
||
RUN pip install --no-cache-dir --upgrade \ | ||
pip~=21.0.1 \ | ||
wheel \ | ||
setuptools | ||
pip~=21.0.1 \ | ||
wheel \ | ||
setuptools | ||
|
||
WORKDIR /build | ||
|
||
|
@@ -96,7 +97,7 @@ COPY --chown=scu:scu services/storage/client-sdk /build/services/storage/client- | |
WORKDIR /build/services/api-server | ||
|
||
RUN pip --no-cache-dir install -r requirements/prod.txt &&\ | ||
pip --no-cache-dir list -v | ||
pip --no-cache-dir list -v | ||
|
||
|
||
# --------------------------Production stage ------------------- | ||
|
@@ -109,7 +110,7 @@ RUN pip --no-cache-dir install -r requirements/prod.txt &&\ | |
FROM base as production | ||
|
||
ENV SC_BUILD_TARGET=production \ | ||
SC_BOOT_MODE=production | ||
SC_BOOT_MODE=production | ||
|
||
ENV PYTHONOPTIMIZE=TRUE | ||
|
||
|
@@ -118,18 +119,27 @@ WORKDIR /home/scu | |
# Starting from clean base image, copies pre-installed virtualenv from prod-only-deps | ||
COPY --chown=scu:scu --from=prod-only-deps ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
|
||
# wget required by wait-for | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
wget \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copies booting scripts | ||
COPY --chown=scu:scu services/api-server/docker services/api-server/docker | ||
RUN chmod +x services/api-server/docker/*.sh | ||
COPY --chown=scu:scu scripts/common-docker-boot/wait-for /usr/local/bin/wait-for | ||
RUN chmod +x /usr/local/bin/wait-for | ||
|
||
HEALTHCHECK --interval=30s \ | ||
--timeout=20s \ | ||
--start-period=30s \ | ||
--retries=3 \ | ||
CMD ["python3", "services/api-server/docker/healthcheck.py", "http://localhost:8000/"] | ||
--timeout=20s \ | ||
--start-period=30s \ | ||
--retries=3 \ | ||
CMD ["python3", "services/api-server/docker/healthcheck.py", "http://localhost:8000/"] | ||
|
||
ENTRYPOINT [ "/bin/sh", "services/api-server/docker/entrypoint.sh" ] | ||
CMD ["/bin/sh", "services/api-server/docker/boot.sh"] | ||
CMD ["/bin/sh", "-c", "wait-for http://migration:8000 -- services/api-server/docker/boot.sh"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are going to have an issue in the deployments here. |
||
|
||
|
||
# --------------------------Development stage ------------------- | ||
|
@@ -148,5 +158,8 @@ WORKDIR /devel | |
|
||
RUN chown -R scu:scu "${VIRTUAL_ENV}" | ||
|
||
COPY --chown=scu:scu scripts/common-docker-boot/wait-for /usr/local/bin/wait-for | ||
RUN chmod +x /usr/local/bin/wait-for | ||
|
||
ENTRYPOINT ["/bin/sh", "services/api-server/docker/entrypoint.sh"] | ||
CMD ["/bin/sh", "services/api-server/docker/boot.sh"] | ||
CMD ["/bin/sh", "-c", "wait-for http://migration:8000 -- services/api-server/docker/boot.sh"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if wget is needed in both dev/prod stages why don't you install it here?