Skip to content

Commit b549825

Browse files
committed
fix apply chown permissions in parallel for large workspace
1 parent d1ae5a9 commit b549825

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ app_setup_block: |
7676
# changelog
7777
changelogs:
7878
- { date: "11.07.21:", desc: "Bump node to 14 to fix builds" }
79+
- { date: "05.07.21:", desc: "Fix slow `chown` on large workspace" }
7980
- { date: "08.05.21:", desc: "Fix doc link" }
8081
- { date: "04.02.20:", desc: "Allow setting gui password via hash using env var `HASHED_PASSWORD`." }
8182
- { date: "23.12.20:", desc: "Allow setting sudo password via hash using env var `SUDO_PASSWORD_HASH`." }

root/etc/cont-init.d/30-config

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,20 @@ if [ -n "${SUDO_PASSWORD}" ] || [ -n "${SUDO_PASSWORD_HASH}" ]; then
1818
fi
1919

2020
# permissions
21-
chown -R abc:abc \
22-
/config
21+
if [ -f "/usr/bin/find" ] && [ -f "/usr/bin/xargs" ]; then
22+
# Split workload between config and workspace
23+
echo "setting permissions::configuration"
24+
CORES=$(nproc --all)
25+
find /config -maxdepth 4 -mindepth 1 -path /config/workspace -prune -false -o -type d | \
26+
xargs --max-args=1 --max-procs=$(($CORES*2*8)) \
27+
chown -R abc:abc
28+
29+
echo "setting permissions::workspace"
30+
chown abc:abc /config/workspace
31+
find /config/workspace -maxdepth 4 -mindepth 1 -type d | \
32+
xargs --max-args=1 --max-procs=$(($CORES*2*16)) \
33+
chown -R abc:abc
34+
else
35+
chown -R abc:abc \
36+
/config
37+
fi

0 commit comments

Comments
 (0)