Skip to content

Commit 772912f

Browse files
committed
aded bolter
1 parent b53461f commit 772912f

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ FROM quay.io/prometheus/node-exporter:v0.15.1 AS node-exporter
33

44
FROM codefresh/dind-cleaner:v1.1 AS dind-cleaner
55

6+
FROM codefresh/bolter AS bolter
7+
68
FROM docker:18.09.5-dind
79
RUN apk add bash jq --no-cache
810
COPY --from=node-exporter /bin/node_exporter /bin/
911
COPY --from=dind-cleaner /usr/local/bin/dind-cleaner /bin/
12+
COPY --from=bolter /go/bin/bolter /bin/
1013

1114
WORKDIR /dind
1215
ADD . /dind

Dockerfile-17.12

Lines changed: 0 additions & 14 deletions
This file was deleted.

Dockerfile.bolter

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Build bolter
2+
FROM golang:1.12.6-alpine3.9
3+
RUN apk add git
4+
RUN go get -u github.com/hasit/bolter
5+

run.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
DIR=$(dirname $0)
44

55
echo "Entering $0 at $(date) "
6-
DIND_VOLUME_STAT_DIR=${DIND_VOLUME_STAT_DIR:-/var/lib/docker/dind-volume}
6+
DOCKERD_DATA_ROOT=${DOCKERD_DATA_ROOT:-/var/lib/docker}
7+
DIND_VOLUME_STAT_DIR=${DIND_VOLUME_STAT_DIR:-${DOCKERD_DATA_ROOT}/dind-volume}
78
DIND_VOLUME_CREATED_TS_FILE=${DIND_VOLUME_STAT_DIR}/created
89
DIND_VOLUME_LAST_USED_TS_FILE=${DIND_VOLUME_STAT_DIR}/last_used
910
DIND_VOLUME_USED_BY_PODS_FILE=${DIND_VOLUME_STAT_DIR}/pods
@@ -127,7 +128,7 @@ MONITOR_PID=$!
127128
### start docker with retry
128129
DOCKERD_PID_FILE=/var/run/docker.pid
129130
DOCKERD_PID_MAXWAIT=${DOCKERD_PID_MAXWAIT:-20}
130-
DOCKER_UP_MAXWAIT=${DOCKERD_UP_MAXWAIT:-90}
131+
DOCKER_UP_MAXWAIT=${DOCKERD_UP_MAXWAIT:-60}
131132
while true
132133
do
133134
[[ -n "${SIGTERM}" ]] && break
@@ -148,9 +149,27 @@ do
148149
fi
149150
sleep 0.5
150151
done
151-
rm -f ${DOCKERD_PID_FILE}
152+
rm -fv ${DOCKERD_PID_FILE}
152153
fi
153154

155+
echo "Checking if other dockerd running on same /var/lib/docker"
156+
CONTEINERD_DB=${DOCKERD_DATA_ROOT}/containerd/daemon/io.containerd.metadata.v1.bolt/meta.db
157+
if [[ -f ${CONTEINERD_DB} ]] && ; then
158+
echo "Checking if another dockerd is running on same ${DOCKERD_DATA_ROOT} boltdb $CONTEINERD_DB is locked"
159+
CNT=0
160+
while ! bolter -f ${CONTEINERD_DB}
161+
do
162+
echo "$(date) - Waiting for containerd boltd ${DOCKERD_PID_FILE}"
163+
(( CNT++ ))
164+
if (( CNT > ${DOCKER_UP_MAXWAIT} )); then
165+
echo " giving up and trying to start docker anyway Waited more than ${DOCKER_UP_MAXWAIT}s for containerd boltdb unlock"
166+
break
167+
fi
168+
sleep 1
169+
done
170+
fi
171+
172+
echo "Starting dockerd"
154173
dockerd ${DOCKERD_PARAMS} <&- &
155174
echo "Waiting at most 20s for docker pid"
156175
CNT=0

0 commit comments

Comments
 (0)