[stable/concourse] properly cleanup btrfs subvolume and children (#14941)

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 <cscosta@pivotal.io>
Co-authored-by: Radoslav Kirilov <rkirilow@gmail.com>
Co-authored-by: Taylor Silva <tsilva@pivotal.io>
This commit is contained in:
Ciro S. Costa
2019-07-04 19:26:35 -07:00
committed by Kubernetes Prow Robot
co-authored by Radoslav Kirilov Taylor Silva
parent b91e719e68
commit 4060f5b566
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -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
@@ -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 }}