Fix MTU configuration for dockerd (#421)

Resolves #393
This commit is contained in:
Yusuke Kuoka
2021-03-31 09:29:21 +09:00
committed by GitHub
parent da4dfb3fdf
commit 156e2c1987
3 changed files with 48 additions and 0 deletions

View File

@@ -7,3 +7,14 @@ spec:
template: template:
spec: spec:
repository: mumoshu/actions-runner-controller-ci repository: mumoshu/actions-runner-controller-ci
#
# dockerd within runner container
#
## Replace `mumoshu/actions-runner-dind:dev` with your dind image
#dockerdWithinRunnerContainer: true
#image: mumoshu/actions-runner-dind:dev
#
# Set the MTU used by dockerd-managed network interfaces (including docker-build)
#
#dockerMTU: 1450

View File

@@ -703,6 +703,7 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{ pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
Name: "docker", Name: "docker",
Image: r.DockerImage, Image: r.DockerImage,
Args: []string{"dockerd"},
VolumeMounts: []corev1.VolumeMount{ VolumeMounts: []corev1.VolumeMount{
{ {
Name: "work", Name: "work",
@@ -731,11 +732,17 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
if mtu := runner.Spec.DockerMTU; mtu != nil { if mtu := runner.Spec.DockerMTU; mtu != nil {
pod.Spec.Containers[1].Env = append(pod.Spec.Containers[1].Env, []corev1.EnvVar{ pod.Spec.Containers[1].Env = append(pod.Spec.Containers[1].Env, []corev1.EnvVar{
// See https://docs.docker.com/engine/security/rootless/
{ {
Name: "DOCKERD_ROOTLESS_ROOTLESSKIT_MTU", Name: "DOCKERD_ROOTLESS_ROOTLESSKIT_MTU",
Value: fmt.Sprintf("%d", *runner.Spec.DockerMTU), Value: fmt.Sprintf("%d", *runner.Spec.DockerMTU),
}, },
}...) }...)
pod.Spec.Containers[1].Args = append(pod.Spec.Containers[1].Args,
"--mtu",
fmt.Sprintf("%d", *runner.Spec.DockerMTU),
)
} }
} }

View File

@@ -17,6 +17,34 @@ function wait_for_process () {
return 0 return 0
} }
sudo /bin/bash <<SCRIPT
mkdir -p /etc/docker
cat <<EOS > /etc/docker/daemon.json
{
EOS
if [ -n "${MTU}" ]; then
cat <<EOS >> /etc/docker/daemon.json
"mtu": ${MTU}
EOS
# See https://docs.docker.com/engine/security/rootless/
echo "environment=DOCKERD_ROOTLESS_ROOTLESSKIT_MTU=${MTU}" >> /etc/supervisor/conf.d/dockerd.conf
fi
cat <<EOS >> /etc/docker/daemon.json
}
EOS
SCRIPT
INFO "Using /etc/docker/daemon.json with the following content"
cat /etc/docker/daemon.json
INFO "Using /etc/supervisor/conf.d/dockerd.conf with the following content"
cat /etc/supervisor/conf.d/dockerd.conf
INFO "Starting supervisor" INFO "Starting supervisor"
sudo /usr/bin/supervisord -n >> /dev/null 2>&1 & sudo /usr/bin/supervisord -n >> /dev/null 2>&1 &
@@ -27,6 +55,8 @@ for process in "${processes[@]}"; do
wait_for_process "$process" wait_for_process "$process"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ERROR "$process is not running after max time" ERROR "$process is not running after max time"
ERROR "Dumping /var/log/dockerd.err.log to help investigation"
cat /var/log/dockerd.err.log
exit 1 exit 1
else else
INFO "$process is running" INFO "$process is running"