forked from vmware/harbor-boshrelease
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load harbor docker images in harbor job prestart instead of job start
This can solve the canary watch timeout issue #3735, because the time of prestart execution is not included in the canary_watch_time. This patch moves docker related utils and bosh env vars to src/common/utils.sh, and the key code for loading images is in jobs/harbor/templates/bin/pre-start.erb. Issue: goharbor/harbor#3735
- Loading branch information
Showing
11 changed files
with
119 additions
and
87 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ templates: | |
bin/properties.sh.erb: bin/properties.sh | ||
|
||
packages: | ||
- common | ||
- docker | ||
|
||
properties: | ||
|
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
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,4 @@ | ||
set -e | ||
|
||
cp -a common/* ${BOSH_INSTALL_TARGET} | ||
chmod +x ${BOSH_INSTALL_TARGET}/*.sh |
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,7 @@ | ||
--- | ||
name: common | ||
|
||
dependencies: [] | ||
|
||
files: | ||
- common/utils.sh |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
name: docker | ||
|
||
dependencies: [] | ||
dependencies: [common] | ||
|
||
files: | ||
- docker/docker-17.06.2-ce.tgz #https://download.docker.com/linux/static/stable/x86_64/docker-17.06.2-ce.tgz |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
name: harbor-common | ||
|
||
dependencies: [] | ||
dependencies: [common] | ||
|
||
files: | ||
- harbor-common/common.sh | ||
|
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,54 @@ | ||
#!/bin/bash | ||
|
||
RUN_DIR=/var/vcap/sys/run | ||
LOG_DIR=/var/vcap/sys/log | ||
JOB_DIR=/var/vcap/jobs | ||
PACKAGE_DIR=/var/vcap/packages | ||
|
||
DOCKER_RUN_DIR=$RUN_DIR/docker | ||
DOCKER_PACKAGE_DIR=${PACKAGE_DIR}/docker | ||
DOCKER_DAEMON_SOCK=${DOCKER_RUN_DIR}/dockerd.sock | ||
DOCKER_HOST="unix://$DOCKER_DAEMON_SOCK" | ||
DOCKER_CMD="${DOCKER_PACKAGE_DIR}/bin/docker -H $DOCKER_HOST" | ||
|
||
log() { | ||
echo [`date`] $* | ||
} | ||
|
||
waitForDockerd() { | ||
sleep_time=3 | ||
timeout=60 | ||
count=0 | ||
while ! $DOCKER_CMD version 2>&1 | ||
do | ||
log "Docker daemon is not running. Waiting for $sleep_time seconds then check again." | ||
sleep $sleep_time | ||
count=$((count + sleep_time)); | ||
if [ $count -ge $timeout ]; then | ||
log "Error: Docker daemon is still not running after $timeout seconds." | ||
exit 1 | ||
fi | ||
done | ||
log "Docker daemon is running" | ||
} | ||
|
||
waitForDockerJobPrestart() { | ||
# All prestart scripts run in parallel. | ||
# The docker job prestart (jobs/docker/templates/bin/pre-start.erb | ||
# should be able to complete in 5 seconds. | ||
sleep 5 | ||
|
||
sleep_time=2 | ||
timeout=60 | ||
count=0 | ||
while ! grep -q "^docker:" /etc/group | ||
do | ||
sleep $sleep_time | ||
count=$((count + sleep_time)); | ||
if [ $count -ge $timeout ]; then | ||
log "Error: docker job prestart doesn't exit in $timeout seconds." | ||
exit 1 | ||
fi | ||
done | ||
log "docker job prestart completed" | ||
} |
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