Drop container logs collected from bind-mounted dirs

Tripleo implementation mounts /var/log/containers/<name> directories to /var/log/<name> in containers.
Such paths should be dropped, otherwise such logs are collected multiple times for each containers.
When debug is enabled, logs (especially libvirt related logs) become too large to be collected in INFO_DIR.
This patch drops paths mounted from the host.

Change-Id: Ic6cd058671a5cedf8e94200937ea2bc852caf79c
This commit is contained in:
Yusuke Okada 2022-11-02 10:44:37 -04:00 committed by Sergii Golovatiuk
parent 6815b0fb1f
commit 2c182bc041

View File

@ -88,7 +88,12 @@ for cont in $(${engine} ps | awk '{print $NF}' | grep -v NAMES); do
# using a `logs` volume
# NOTE(mandre) Do not copy logs if the containers is bind mounting /var/log directory
if ! ${engine} inspect "$cont" | jq .[0].Mounts[].Source | grep -x '"/var/log[/]*"' >/dev/null 2>&1; then
container_cp "$cont" /var/log "$INFO_DIR/log";
container_cp "$cont" /var/log "$INFO_DIR/log";
BIND_DESTS=$(${engine} inspect "$cont" | jq .[0].Mounts[].Destination -r)
for path in $(echo "$BIND_DESTS" | grep "^/var/log" | sed -e "s#^/var/log/##g"); do
rm -rf "$INFO_DIR/log/$path"
echo "Omitting $INFO_DIR/log/$path in $cont because it is mounted from the host"
done
fi;
# Delete symlinks because they break log collection and are generally