concourse / concourse-chart

Helm chart to install Concourse
Apache License 2.0
145 stars 176 forks source link

Worker disks not cleaned up on pod start (incl. solution) #360

Open suhlig opened 4 months ago

suhlig commented 4 months ago

Describe the bug

I believe I found a bug in the chart that would explain why the disks of our workers keep growing and are not emptied out upon worker start.

When deploying the workers as StatefulSet, an init container is created for each worker to clear out the concourse-work-dir on start. The workDir argument to rm -rf is generated with the asterisk in the quotes, which makes it match nothing in bash.

Reproduction steps

This bug can be reproduced even outside Concourse:

$ mkdir -p /tmp/concourse-work-dir
$ touch /tmp/concourse-work-dir/{foo,bar,baz}
$ ls /tmp/concourse-work-dir
bar     baz     foo

Ok, now let's remove the files using a similar rm -rf statement, including the asterisk within the quotes:

$ rm -rf "/tmp/concourse-work-dir/*"
$ echo $?
0
$ ls /tmp/concourse-work-dir
bar     baz     foo

All files are still there! Let's move the asterisk outside the quotes and try again:

$ rm -rf "/tmp/concourse-work-dir/"*
$ ls /tmp/concourse-work-dir

Empty, as desired.

Expected behavior

The directory behind {{ .Values.concourse.worker.workDir }} should be empty after the init container finished.

Additional context

The fix is to move the asterisk outside the quotes. I'll open a separate PR for this.