Fix regression of collect-logs package listing

Collection package list from container is failing with
Error:-
    unexpected EOF while looking for matching `)'

Issue is caused by https://review.openstack.org/#/c/610491/

This patch also does following apart from fixing the issue:
- Redirect stderr also to container info file
- use subshell instead of bash array to add readability
- use 'set -x' to print command instead of echo "+ $cmd"
- Also remove extra blank lines from container ALL_INFO file

Change-Id: Iff347eeed47c64af14bcd181d104c94612663802
Story: https://tree.taiga.io/project/tripleo-ci-board/task/377
This commit is contained in:
Sorin Sbarnea 2018-11-15 13:14:52 +00:00 committed by Quique Llorente
parent 6831717802
commit ab6e39d26c
1 changed files with 13 additions and 19 deletions

View File

@ -255,25 +255,19 @@
for cont in $(${engine} ps | awk {'print $NF'} | grep -v NAMES); do
INFO_DIR=$BASE_CONTAINER_EXTRA/containers/${cont};
mkdir -p $INFO_DIR;
INFO_FILE=${INFO_DIR}/${engine}_info.log;
CONTAINER_CONT_INFO_CMDS=(
"${engine} exec $cont top -bwn1"
"${engine} exec $cont bash -c \"\$(command -v dnf || command -v yum) list installed\""
"${engine} inspect $cont"
);
if [ $engine = 'docker' ]; then
CONTAINER_CONT_INFO_CMDS+=("${engine} top $cont auxw");
fi
# NOTE(cjeanner): `podman top` does not support `ps` options.
if [ $engine = 'podman' ]; then
CONTAINER_CONT_INFO_CMDS+=("${engine} top $cont");
fi
for cmd in "${CONTAINER_CONT_INFO_CMDS[@]}"; do
echo "+ $cmd" >> $INFO_FILE;
$cmd >> $INFO_FILE;
echo "" >> $ALL_FILE;
echo "" >> $ALL_FILE;
done;
(
set -x;
if [ $engine = 'docker' ]; then
${engine} top $cont auxw;
# NOTE(cjeanner): `podman top` does not support `ps` options.
elif [ $engine = 'podman' ]; then
${engine} top $cont;
fi
${engine} exec $cont top -bwn1;
${engine} exec $cont bash -c "\$(command -v dnf || command -v yum) list installed";
${engine} inspect $cont;
) &> $INFO_DIR/${engine}_info.log;
${engine} logs $cont &> $INFO_DIR/stdout.log;
container_cp $cont /var/lib/kolla/config_files/config.json $INFO_DIR/config.json;