From 6127ca8786c216df3690c80c84b40a71db4f3128 Mon Sep 17 00:00:00 2001 From: Riccardo Schirone <562321+ret2libc@users.noreply.github.com> Date: Wed, 30 Apr 2025 09:54:26 +0200 Subject: [PATCH] Wait for DinD to be ready (#490) * deployment/charts: start dind first * Wait for DinD to be up and running --- common/container-entrypoint.sh | 12 ++++++++++++ .../k8s/charts/build-bot/templates/deployment.yaml | 2 +- .../charts/competition-api/templates/deployment.yaml | 2 +- .../charts/coverage-bot/templates/deployment.yaml | 2 +- .../k8s/charts/patcher/templates/deployment.yaml | 2 +- .../charts/program-model/templates/deployment.yaml | 2 +- .../k8s/charts/seed-gen/templates/deployment.yaml | 2 +- .../k8s/charts/tracer-bot/templates/deployment.yaml | 2 +- fuzzer/dockerfiles/runner_image.Dockerfile | 3 +++ patcher/Dockerfile | 2 ++ program-model/Dockerfile | 3 +++ seed-gen/Dockerfile | 3 +++ 12 files changed, 30 insertions(+), 7 deletions(-) create mode 100755 common/container-entrypoint.sh diff --git a/common/container-entrypoint.sh b/common/container-entrypoint.sh new file mode 100755 index 00000000..b31a129c --- /dev/null +++ b/common/container-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Wait for the Docker host to be ready to accept connections +if [ -n "$DOCKER_HOST" ]; then + echo "Waiting for Docker daemon to be ready..." + while ! docker info > /dev/null 2>&1; do + sleep 1 + done +fi + +# Run the command passed as arguments +exec "$@" diff --git a/deployment/k8s/charts/build-bot/templates/deployment.yaml b/deployment/k8s/charts/build-bot/templates/deployment.yaml index 40b78bb6..0be21c05 100644 --- a/deployment/k8s/charts/build-bot/templates/deployment.yaml +++ b/deployment/k8s/charts/build-bot/templates/deployment.yaml @@ -19,6 +19,7 @@ spec: initContainers: {{- include "buttercup.waitForRedis" . | nindent 6 }} containers: + {{- include "buttercup.dindSidecar" . | nindent 6 }} - name: build-bot image: "{{ .Values.global.fuzzerImage.repository }}:{{ .Values.global.fuzzerImage.tag }}" imagePullPolicy: {{ .Values.global.fuzzerImage.pullPolicy }} @@ -32,7 +33,6 @@ spec: {{- include "buttercup.commonEnv" . | nindent 8 }} {{- include "buttercup.buildBotEnv" . | nindent 8 }} {{- include "buttercup.dockerHostEnv" . | nindent 8 }} - {{- include "buttercup.dindSidecar" . | nindent 6 }} volumes: {{- include "buttercup.volumes.scratch" . | nindent 6 }} {{- include "buttercup.volumes.tasks" . | nindent 6 }} diff --git a/deployment/k8s/charts/competition-api/templates/deployment.yaml b/deployment/k8s/charts/competition-api/templates/deployment.yaml index 162a1a54..7bdb26a8 100644 --- a/deployment/k8s/charts/competition-api/templates/deployment.yaml +++ b/deployment/k8s/charts/competition-api/templates/deployment.yaml @@ -17,6 +17,7 @@ spec: spec: {{- include "buttercup.imagePullSecrets" . | nindent 6 }} containers: + {{- include "buttercup.dindSidecar" . | nindent 8 }} - name: competition-api image: "{{ .Values.global.competitionApiImage.repository }}:{{ .Values.global.competitionApiImage.tag }}" imagePullPolicy: {{ .Values.global.competitionApiImage.pullPolicy }} @@ -55,7 +56,6 @@ spec: {{- end }} {{- end }} {{- include "buttercup.nodeLocalVolumeMount" . | nindent 12 }} - {{- include "buttercup.dindSidecar" . | nindent 8 }} volumes: {{- include "buttercup.dindVolume" . | nindent 8 }} {{- include "buttercup.volumes.scratch" . | nindent 8 }} diff --git a/deployment/k8s/charts/coverage-bot/templates/deployment.yaml b/deployment/k8s/charts/coverage-bot/templates/deployment.yaml index 7c145bae..ebb6184c 100644 --- a/deployment/k8s/charts/coverage-bot/templates/deployment.yaml +++ b/deployment/k8s/charts/coverage-bot/templates/deployment.yaml @@ -19,6 +19,7 @@ spec: initContainers: {{- include "buttercup.waitForRedis" . | nindent 6 }} containers: + {{- include "buttercup.dindSidecar" . | nindent 6 }} - name: coverage-bot image: "{{ .Values.global.fuzzerImage.repository }}:{{ .Values.global.fuzzerImage.tag }}" imagePullPolicy: {{ .Values.global.fuzzerImage.pullPolicy }} @@ -33,7 +34,6 @@ spec: value: "{{ .Values.global.coverageBot.sampleSize }}" {{- include "buttercup.dockerHostEnv" . | nindent 8 }} {{- include "buttercup.env.nodeData" . | nindent 8 }} - {{- include "buttercup.dindSidecar" . | nindent 6 }} volumes: {{- include "buttercup.volumes.scratch" . | nindent 6 }} {{- include "buttercup.volumes.tasks" . | nindent 6 }} diff --git a/deployment/k8s/charts/patcher/templates/deployment.yaml b/deployment/k8s/charts/patcher/templates/deployment.yaml index b7caa7ae..37c93490 100644 --- a/deployment/k8s/charts/patcher/templates/deployment.yaml +++ b/deployment/k8s/charts/patcher/templates/deployment.yaml @@ -21,6 +21,7 @@ spec: {{- include "buttercup.waitForRedis" . | nindent 6 }} {{- include "buttercup.waitForLiteLLM" . | nindent 6 }} containers: + {{- include "buttercup.dindSidecar" . | nindent 6 }} - name: patcher image: "{{ .Values.global.patcherImage.repository | default "patcher" }}:{{ .Values.global.patcherImage.tag | default "latest" }}" imagePullPolicy: {{ .Values.global.patcherImage.pullPolicy | default "IfNotPresent" }} @@ -38,7 +39,6 @@ spec: {{- include "buttercup.env.langfuse" . | nindent 8 }} - name: LOG_LEVEL value: "{{ .Values.logLevel }}" - {{- include "buttercup.dindSidecar" . | nindent 6 }} volumes: {{- include "buttercup.volumes.scratch" . | nindent 6 }} {{- include "buttercup.dindVolume" . | nindent 6 }} diff --git a/deployment/k8s/charts/program-model/templates/deployment.yaml b/deployment/k8s/charts/program-model/templates/deployment.yaml index e91fb970..db173fc7 100644 --- a/deployment/k8s/charts/program-model/templates/deployment.yaml +++ b/deployment/k8s/charts/program-model/templates/deployment.yaml @@ -19,6 +19,7 @@ spec: initContainers: {{- include "buttercup.waitForRedis" . | nindent 6 }} containers: + {{- include "buttercup.dindSidecar" . | nindent 6 }} - name: program-model image: "{{ .Values.global.programModelImage.repository }}:{{ .Values.global.programModelImage.tag }}" imagePullPolicy: {{ .Values.global.programModelImage.pullPolicy }} @@ -32,7 +33,6 @@ spec: volumeMounts: {{- include "buttercup.standardVolumeMounts" (dict "usesTasksStorage" true) | nindent 8 }} {{- include "buttercup.nodeLocalVolumeMount" . | nindent 8 }} - {{- include "buttercup.dindSidecar" . | nindent 6 }} volumes: {{- include "buttercup.volumes.scratch" . | nindent 6 }} {{- include "buttercup.volumes.tasks" . | nindent 6 }} diff --git a/deployment/k8s/charts/seed-gen/templates/deployment.yaml b/deployment/k8s/charts/seed-gen/templates/deployment.yaml index 0f5075b1..e4ee6b4a 100644 --- a/deployment/k8s/charts/seed-gen/templates/deployment.yaml +++ b/deployment/k8s/charts/seed-gen/templates/deployment.yaml @@ -21,6 +21,7 @@ spec: {{- include "buttercup.waitForRedis" . | nindent 6 }} {{- include "buttercup.waitForLiteLLM" . | nindent 6 }} containers: + {{- include "buttercup.dindSidecar" . | nindent 6 }} - name: seed-gen image: "{{ .Values.global.seedGenImage.repository }}:{{ .Values.global.seedGenImage.tag }}" imagePullPolicy: {{ .Values.global.seedGenImage.pullPolicy }} @@ -45,7 +46,6 @@ spec: {{- include "buttercup.env.langfuse" . | nindent 8 }} - name: LOG_LEVEL value: "{{ include "buttercup.core.logLevel" . }}" - {{- include "buttercup.dindSidecar" . | nindent 6 }} volumes: {{- include "buttercup.volumes.scratch" . | nindent 6 }} {{- include "buttercup.dindVolume" . | nindent 6 }} diff --git a/deployment/k8s/charts/tracer-bot/templates/deployment.yaml b/deployment/k8s/charts/tracer-bot/templates/deployment.yaml index 9067377d..7536b59d 100644 --- a/deployment/k8s/charts/tracer-bot/templates/deployment.yaml +++ b/deployment/k8s/charts/tracer-bot/templates/deployment.yaml @@ -19,6 +19,7 @@ spec: initContainers: {{- include "buttercup.waitForRedis" . | nindent 6 }} containers: + {{- include "buttercup.dindSidecar" . | nindent 6 }} - name: tracer-bot image: "{{ .Values.global.fuzzerImage.repository }}:{{ .Values.global.fuzzerImage.tag }}" imagePullPolicy: {{ .Values.global.fuzzerImage.pullPolicy }} @@ -31,7 +32,6 @@ spec: env: {{- include "buttercup.dockerHostEnv" . | nindent 8 }} {{- include "buttercup.env.nodeData" . | nindent 8 }} - {{- include "buttercup.dindSidecar" . | nindent 6 }} volumes: {{- include "buttercup.volumes.scratch" . | nindent 6 }} {{- include "buttercup.volumes.tasks" . | nindent 6 }} diff --git a/fuzzer/dockerfiles/runner_image.Dockerfile b/fuzzer/dockerfiles/runner_image.Dockerfile index 658d5e09..4ed59c15 100644 --- a/fuzzer/dockerfiles/runner_image.Dockerfile +++ b/fuzzer/dockerfiles/runner_image.Dockerfile @@ -41,4 +41,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ && rm -rf /var/lib/apt/lists/* COPY --from=builder --chown=app:app /fuzzer/.venv /fuzzer/.venv +COPY common/container-entrypoint.sh /container-entrypoint.sh ENV PATH=/fuzzer/.venv/bin:$PATH + +ENTRYPOINT ["/container-entrypoint.sh"] diff --git a/patcher/Dockerfile b/patcher/Dockerfile index 5177f84b..be0ab1fa 100644 --- a/patcher/Dockerfile +++ b/patcher/Dockerfile @@ -60,7 +60,9 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ COPY --from=builder --chown=app:app /app/patcher/.venv /app/patcher/.venv COPY --from=cscope-builder /usr/local/bin/cscope /usr/local/bin/cscope +COPY common/container-entrypoint.sh /container-entrypoint.sh WORKDIR /app/patcher ENV PATH=/app/patcher/.venv/bin:$PATH +ENTRYPOINT ["/container-entrypoint.sh"] diff --git a/program-model/Dockerfile b/program-model/Dockerfile index 2bb11609..b5b76b51 100644 --- a/program-model/Dockerfile +++ b/program-model/Dockerfile @@ -45,4 +45,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ COPY --from=cscope-builder /usr/local/bin/cscope /usr/local/bin/cscope COPY --from=builder --chown=app:app /app/.venv /app/.venv +COPY common/container-entrypoint.sh /container-entrypoint.sh ENV PATH=/app/.venv/bin:$PATH + +ENTRYPOINT ["/container-entrypoint.sh"] diff --git a/seed-gen/Dockerfile b/seed-gen/Dockerfile index e9ae2674..2b4a5a43 100644 --- a/seed-gen/Dockerfile +++ b/seed-gen/Dockerfile @@ -52,6 +52,9 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update \ ENV PYTHON_WASM_BUILD_PATH="/python-3.12.0.wasm" COPY --from=cscope-builder /usr/local/bin/cscope /usr/local/bin/cscope COPY --from=builder /app/seed-gen/.venv /app/seed-gen/.venv +COPY common/container-entrypoint.sh /container-entrypoint.sh + WORKDIR /app/seed-gen ENV PATH=/app/seed-gen/.venv/bin:$PATH +ENTRYPOINT ["/container-entrypoint.sh"]