Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
[stable/concourse] properly cleanup btrfs subvolume and children (#14941
Browse files Browse the repository at this point in the history
)

When a `dind` (Docker in Docker) image is used with btrfs to e.g. run
integration tests as per https://hub.docker.com/r/amidos/dcind/ in some
occasions like job errors or interruptions the btrfs subvolumes are left
not cleaned.

So what happens then is that when the `rm -rf /concourse-worker-dir`
runs it fails with `Operation not permitted` error which then causes
`Init:Error` and ends in `Init:CrashLoopBackOff`.

The solution is to take that into account and properly delete all of the
btrfs subvolumes.

This can be achieved either with the suggested script or with the mount
option [user_subvol_rm_allowed](https://askubuntu.com/questions/509292/how-to-set-user-subvol-rm-allowed-capability)
that is tricky to apply or with that delete script that seems as a
better option.

Signed-off-by: Ciro S. Costa <[email protected]>
Co-authored-by: Radoslav Kirilov <[email protected]>
Co-authored-by: Taylor Silva <[email protected]>
  • Loading branch information
3 people authored and k8s-ci-robot committed Jul 5, 2019
1 parent b91e719 commit 4060f5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion stable/concourse/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: concourse
version: 8.0.0
version: 8.0.1
appVersion: 5.3.0
description: Concourse is a simple and scalable CI system.
icon: https://avatars1.githubusercontent.com/u/7809479
Expand Down
9 changes: 7 additions & 2 deletions stable/concourse/templates/worker-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,17 @@ spec:
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
{{- end }}
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
securityContext:
privileged: true
command:
- /bin/sh
- /bin/bash
args:
- -ce
- |-
rm -rf {{ .Values.concourse.worker.workDir }}/*
for v in $((btrfs subvolume list --sort=-ogen "{{ .Values.concourse.worker.workDir }}" || true) | awk '{print $9}'); do
(btrfs subvolume show "{{ .Values.concourse.worker.workDir }}/$v" && btrfs subvolume delete "{{ .Values.concourse.worker.workDir }}/$v") || true
done
rm -rf "{{ .Values.concourse.worker.workDir }}/*"
volumeMounts:
- name: concourse-work-dir
mountPath: {{ .Values.concourse.worker.workDir | quote }}
Expand Down

0 comments on commit 4060f5b

Please sign in to comment.