Commit ce73154
authored
Swarming: Avoids mounting volume (#5213)
## Overview
Swarming, as well as K8S has issues when trying to mount this volume to
the container.
```bash
mount /mnt/scratch0 -o remount,exec,suid,dev
```
So we added a validation to not mount when we are either in K8S or in
swarming.
Note: Uses SWARMING_BOT env var as its the one we [already use in the
swarming
request](https://github.com/google/clusterfuzz/blob/master/src/clusterfuzz/_internal/swarming/__init__.py#L134)
## Tests performed
I created a custom bash script to test this:
```bash
is_truthy() {
[[ "$1" =~ ^([Tt]rue|1)$ ]]
}
should_mount() {
if is_truthy "$IS_K8S_ENV" || is_truthy "$SWARMING_BOT"; then
return 1
fi
return 0
}
test_mount() {
unset IS_K8S_ENV SWARMING_BOT
[[ "$1" != "unset" ]] && export IS_K8S_ENV=$1
[[ "$2" != "unset" ]] && export SWARMING_BOT=$2
printf "IS_K8S_ENV=%-5s | SWARMING_BOT=%-5s =>" "$1" "$2"
if should_mount; then echo " [MOUNT EXECUTED]"; else echo " [MOUNT SKIPPED]"; fi
}
'
```
Against multiple inputs:
```bash
echo "=== DRY RUN OUTPUT USING is_truthy() ==="
test_mount "unset" "unset"
test_mount "1" "unset"
test_mount "true" "unset"
test_mount "false" "unset"
test_mount "False" "unset"
test_mount "0" "unset"
test_mount "unset" "True"
test_mount "unset" "1"
test_mount "unset" "false"
test_mount "false" "false"
```
And got this results:
```bash
=== DRY RUN OUTPUT USING is_truthy() ===
IS_K8S_ENV=unset | SWARMING_BOT=unset => [MOUNT EXECUTED]
IS_K8S_ENV=1 | SWARMING_BOT=unset => [MOUNT SKIPPED]
IS_K8S_ENV=true | SWARMING_BOT=unset => [MOUNT SKIPPED]
IS_K8S_ENV=false | SWARMING_BOT=unset => [MOUNT EXECUTED]
IS_K8S_ENV=False | SWARMING_BOT=unset => [MOUNT EXECUTED]
IS_K8S_ENV=0 | SWARMING_BOT=unset => [MOUNT EXECUTED]
IS_K8S_ENV=unset | SWARMING_BOT=True => [MOUNT SKIPPED]
IS_K8S_ENV=unset | SWARMING_BOT=1 => [MOUNT SKIPPED]
IS_K8S_ENV=unset | SWARMING_BOT=false => [MOUNT EXECUTED]
IS_K8S_ENV=false | SWARMING_BOT=false => [MOUNT EXECUTED]
```1 parent 2a97787 commit ce73154
1 file changed
Lines changed: 15 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
| |||
0 commit comments