Skip to content

Commit 92609de

Browse files
authored
Merge pull request #1828 from manics/remove-incorrect-docker-socket
Remove incorrect docker socket if found
2 parents 1ec6193 + d6c6604 commit 92609de

File tree

5 files changed

+57
-37
lines changed

5 files changed

+57
-37
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ jobs:
299299
timeout: 150
300300
max-restarts: 1
301301

302+
- name: Test the workaround for an incorrect docker.sock directory
303+
if: matrix.test-variation == 'dind'
304+
run: |
305+
# {{ .Values.dind.hostSocketDir }}/{{ .Values.dind.hostSocketName }}
306+
sudo mkdir -p /var/run/dind/docker.sock
307+
302308
- name: Install the chart
303309
if: matrix.test == 'helm'
304310
run: |

helm-chart/binderhub/schema.yaml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,20 @@ properties:
417417
storageDriver:
418418
type: string
419419
description: |
420-
TODO
420+
Docker storage driver
421421
resources: *resources-spec
422-
hostSocketDir:
422+
hostSocketDir: &hostSocketDir-spec
423423
type: string
424424
description: |
425-
TODO
426-
hostLibDir:
425+
Host directory where the container socket will be located
426+
hostLibDir: &hostStorageDir-spec
427427
type: string
428428
description: |
429-
TODO
429+
Host directory where the containers storage will be located
430+
hostSocketName: &hostSocketName-spec
431+
type: string
432+
description: |
433+
Name of the container socket file
430434
431435
pink:
432436
type: object
@@ -446,14 +450,9 @@ properties:
446450
extraVolumes: *extraVolumes-spec
447451
extraVolumeMounts: *extraVolumeMounts-spec
448452
resources: *resources-spec
449-
hostStorageDir:
450-
type: string
451-
description: |
452-
Host path where the containers storage will be located
453-
hostSocketDir:
454-
type: string
455-
description: |
456-
Host path where the podman socket will be located
453+
hostStorageDir: *hostStorageDir-spec
454+
hostSocketDir: *hostSocketDir-spec
455+
hostSocketName: *hostSocketName-spec
457456

458457
imageCleaner:
459458
type: object

helm-chart/binderhub/templates/container-builder/daemonset.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{{- $builderName := .Values.imageBuilderType -}}
33
{{- $builder := index .Values $builderName -}}
44
{{- $daemonset := $builder.daemonset -}}
5+
{{- $hostSocketPath := printf "%s/%s" $builder.hostSocketDir $builder.hostSocketName }}
56

67
apiVersion: apps/v1
78
kind: DaemonSet
@@ -36,8 +37,27 @@ spec:
3637
value: user
3738
nodeSelector: {{ .Values.config.BinderHub.build_node_selector | toJson }}
3839

39-
{{- with $builder.initContainers }}
4040
initContainers:
41+
- name: filesystem
42+
# Reuse the main container image since this is a simple shell command
43+
image: {{ $daemonset.image.name }}:{{ $daemonset.image.tag }}
44+
{{- with $daemonset.image.pullPolicy }}
45+
imagePullPolicy: {{ . }}
46+
{{- end }}
47+
command:
48+
- sh
49+
- -c
50+
- >
51+
if [ -d "{{ $hostSocketPath }}" ]; then
52+
echo "Removing incorrect socket directory {{ $hostSocketPath }}";
53+
rmdir "{{ $hostSocketPath }}";
54+
fi
55+
securityContext:
56+
privileged: true
57+
volumeMounts:
58+
- name: run-{{ $builderName }}
59+
mountPath: {{ $builder.hostSocketDir }}
60+
{{- with $builder.initContainers }}
4161
{{- . | toYaml | nindent 8 }}
4262
{{- end }}
4363

@@ -55,7 +75,7 @@ spec:
5575
args:
5676
- dockerd
5777
- --storage-driver={{ $builder.storageDriver }}
58-
- -H unix://{{ $builder.hostSocketDir }}/docker.sock
78+
- -H unix://{{ $hostSocketPath }}
5979
{{- with $daemonset.extraArgs }}
6080
{{- . | toYaml | nindent 12 }}
6181
{{- end }}
@@ -73,7 +93,7 @@ spec:
7393
- system
7494
- service
7595
- --time=0
76-
- unix://{{ $builder.hostSocketDir }}/podman.sock
96+
- unix://{{ $hostSocketPath }}
7797
{{- with $daemonset.extraArgs }}
7898
{{- . | toYaml | nindent 12 }}
7999
{{- end }}

helm-chart/binderhub/templates/image-cleaner.yaml

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{{- if .Values.imageCleaner.enabled -}}
2+
{{- $builderName := .Values.imageBuilderType -}}
3+
{{- $builder := index .Values $builderName -}}
4+
25
apiVersion: apps/v1
36
kind: DaemonSet
47
metadata:
@@ -35,23 +38,23 @@ spec:
3538
serviceAccountName: {{ .Release.Name }}-image-cleaner
3639
{{- end }}
3740
containers:
38-
- name: image-cleaner-{{ .Values.imageBuilderType }}
41+
- name: image-cleaner-{{ $builderName }}
3942
image: {{ .Values.imageCleaner.image.name }}:{{ .Values.imageCleaner.image.tag }}
4043
{{- with .Values.imageCleaner.image.pullPolicy }}
4144
imagePullPolicy: {{ . }}
4245
{{- end }}
4346
volumeMounts:
44-
- name: storage-{{ .Values.imageBuilderType }}
45-
mountPath: /var/lib/{{ .Values.imageBuilderType }}
46-
- name: socket-{{ .Values.imageBuilderType }}
47+
- name: storage-{{ $builderName }}
48+
mountPath: /var/lib/{{ $builderName }}
49+
- name: socket-{{ $builderName }}
4750
mountPath: /var/run/docker.sock
4851
env:
4952
- name: DOCKER_IMAGE_CLEANER_NODE_NAME
5053
valueFrom:
5154
fieldRef:
5255
fieldPath: spec.nodeName
5356
- name: DOCKER_IMAGE_CLEANER_PATH_TO_CHECK
54-
value: /var/lib/{{ .Values.imageBuilderType }}
57+
value: /var/lib/{{ $builderName }}
5558
- name: DOCKER_IMAGE_CLEANER_DELAY_SECONDS
5659
value: {{ .Values.imageCleaner.delay | quote }}
5760
- name: DOCKER_IMAGE_CLEANER_THRESHOLD_TYPE
@@ -62,7 +65,7 @@ spec:
6265
value: {{ .Values.imageCleaner.imageGCThresholdLow | quote }}
6366
terminationGracePeriodSeconds: 0
6467
volumes:
65-
{{- if eq .Values.imageBuilderType "host" }}
68+
{{- if eq $builderName "host" }}
6669
- name: storage-host
6770
hostPath:
6871
path: {{ .Values.imageCleaner.host.dockerLibDir }}
@@ -71,24 +74,14 @@ spec:
7174
path: {{ .Values.imageCleaner.host.dockerSocket }}
7275
type: Socket
7376
{{- end }}
74-
{{- if eq .Values.imageBuilderType "dind" }}
75-
- name: storage-dind
77+
{{- if or (eq $builderName "dind") (eq $builderName "pink") }}
78+
- name: storage-{{ $builderName }}
7679
hostPath:
77-
path: {{ .Values.dind.hostLibDir }}
80+
path: {{ eq $builderName "dind" | ternary $builder.hostLibDir $builder.hostStorageDir }}
7881
type: DirectoryOrCreate
79-
- name: socket-dind
82+
- name: socket-{{ $builderName }}
8083
hostPath:
81-
path: {{ .Values.dind.hostSocketDir }}/docker.sock
82-
type: Socket
83-
{{- end }}
84-
{{- if eq .Values.imageBuilderType "pink" }}
85-
- name: storage-pink
86-
hostPath:
87-
path: {{ .Values.pink.hostStorageDir }}
88-
type: DirectoryOrCreate
89-
- name: socket-pink
90-
hostPath:
91-
path: {{ .Values.pink.hostSocketDir }}/podman.sock
84+
path: {{ $builder.hostSocketDir }}/{{ $builder.hostSocketName }}
9285
type: Socket
9386
{{- end }}
9487
{{- end }}

helm-chart/binderhub/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ dind:
288288
resources: {}
289289
hostSocketDir: /var/run/dind
290290
hostLibDir: /var/lib/dind
291+
hostSocketName: docker.sock
291292

292293
# Podman in Kubernetes
293294
pink:
@@ -304,6 +305,7 @@ pink:
304305
resources: {}
305306
hostStorageDir: /var/lib/pink/storage
306307
hostSocketDir: /var/run/pink
308+
hostSocketName: podman.sock
307309

308310
imageCleaner:
309311
enabled: true

0 commit comments

Comments
 (0)