Skip to content

Commit 9579f9c

Browse files
authored
Added batching of chown operations (#146)
1 parent 94e023a commit 9579f9c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

7.9/docker-entrypoint.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,16 @@ if [ "$1" = './ignition-gateway' ]; then
458458
)
459459
readarray -d '' pa_ignition_files < <(find "${ignition_paths[@]}" \! \( -user "${IGNITION_UID}" -group "${IGNITION_GID}" \) -print0)
460460
if (( ${#pa_ignition_files[@]} > 0 )); then
461-
echo "init | Adjusting ownership of ${#pa_ignition_files[@]} Ignition installation files..."
462-
# ignore failures with '|| true' here due to potentially broken symlink to metro-keystore (fresh launch)
463-
chown -h -f "${IGNITION_UID}:${IGNITION_GID}" "${pa_ignition_files[@]}" || true
461+
batch_size=500
462+
echo "init | Adjusting ownership of ${#pa_ignition_files[@]} Ignition installation files (batch size ${batch_size})..."
463+
looper=0
464+
pa_ignition_files_batch=( "${pa_ignition_files[@]:$looper:$batch_size}" )
465+
while (( ${#pa_ignition_files_batch[@]} > 0 )); do
466+
# ignore failures with '|| true' here due to potentially broken symlink to metro-keystore (fresh launch)
467+
chown -h -f "${IGNITION_UID}:${IGNITION_GID}" "${pa_ignition_files_batch[@]}" || true
468+
looper=$((looper+batch_size))
469+
pa_ignition_files_batch=( "${pa_ignition_files[@]:$looper:$batch_size}" )
470+
done
464471
fi
465472

466473
echo "init | Staging user step-down from 'root'"

8.1/docker-entrypoint.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,9 +748,16 @@ if [[ "$1" != 'bash' && "$1" != 'sh' && "$1" != '/bin/sh' ]]; then
748748
)
749749
readarray -d '' pa_ignition_files < <(find "${ignition_paths[@]}" \! \( -user "${IGNITION_UID}" -group "${IGNITION_GID}" \) -print0)
750750
if (( ${#pa_ignition_files[@]} > 0 )); then
751-
echo "init | Adjusting ownership of ${#pa_ignition_files[@]} Ignition installation files..."
752-
# ignore failures with '|| true' here due to potentially broken symlink to metro-keystore (fresh launch)
753-
chown -h -f "${IGNITION_UID}:${IGNITION_GID}" "${pa_ignition_files[@]}" || true
751+
batch_size=500
752+
echo "init | Adjusting ownership of ${#pa_ignition_files[@]} Ignition installation files (batch size ${batch_size})..."
753+
looper=0
754+
pa_ignition_files_batch=( "${pa_ignition_files[@]:$looper:$batch_size}" )
755+
while (( ${#pa_ignition_files_batch[@]} > 0 )); do
756+
# ignore failures with '|| true' here due to potentially broken symlink to metro-keystore (fresh launch)
757+
chown -h -f "${IGNITION_UID}:${IGNITION_GID}" "${pa_ignition_files_batch[@]}" || true
758+
looper=$((looper+batch_size))
759+
pa_ignition_files_batch=( "${pa_ignition_files[@]:$looper:$batch_size}" )
760+
done
754761
fi
755762

756763
echo "init | Staging user step-down from 'root'"

0 commit comments

Comments
 (0)