Add podman support for log collection
We want to ensure we get all the logs we want, from both docker and podman engines, even if we get some mixed environment for some reason. Change-Id: I00e2f9b7755b7e32b7ed20b482d851aacb17464e
This commit is contained in:
parent
543ee8faf4
commit
47914f502d
|
@ -105,7 +105,13 @@
|
|||
|
||||
- name: check if ODL is enabled via docker
|
||||
shell: docker ps | grep opendaylight_api
|
||||
register: odl_docker_enabled
|
||||
register: odl_container_enabled
|
||||
|
||||
- name: check if ODL is enabled via podman
|
||||
shell: podman ps | grep opendaylight_api
|
||||
register: odl_container_enabled
|
||||
when: odl_container_enabled.rc != 0
|
||||
|
||||
|
||||
- name: check if ODL is enabled via rpm
|
||||
shell: rpm -qa | grep opendaylight
|
||||
|
@ -113,7 +119,7 @@
|
|||
|
||||
- name: Create ODL log directory
|
||||
file: dest="{{ odl_extra_log_dir }}" state=directory
|
||||
when: (odl_rpm_enabled.rc == 0) or (odl_docker_enabled.rc == 0)
|
||||
when: (odl_rpm_enabled.rc == 0) or (odl_container_enabled.rc == 0)
|
||||
|
||||
- name: Create rsync filter file
|
||||
template:
|
||||
|
@ -122,7 +128,7 @@
|
|||
|
||||
- name: Collect OVS outputs for ODL
|
||||
shell: "bash /tmp/odl_extra_logs.sh"
|
||||
when: (odl_rpm_enabled.rc == 0) or (odl_docker_enabled.rc == 0)
|
||||
when: (odl_rpm_enabled.rc == 0) or (odl_container_enabled.rc == 0)
|
||||
|
||||
- name: Collect ODL info and logs (RPM deployment)
|
||||
shell: >
|
||||
|
@ -190,46 +196,57 @@
|
|||
mv /tmp/delorean_logs/home/{{ undercloud_user }}/DLRN/data/repos/* {{ artcl_collect_dir }}/delorean_logs/;
|
||||
fi
|
||||
|
||||
- name: Collect docker info and logs
|
||||
- name: Collect container info and logs
|
||||
shell: >
|
||||
if command -v docker && systemctl is-active docker; then
|
||||
BASE_DOCKER_EXTRA=/var/log/extra/docker;
|
||||
mkdir -p $BASE_DOCKER_EXTRA;
|
||||
ALL_FILE=$BASE_DOCKER_EXTRA/docker_allinfo.log;
|
||||
for engine in docker podman; do
|
||||
|
||||
DOCKER_INFO_CMDS=(
|
||||
"docker ps --all --size"
|
||||
"docker images"
|
||||
"docker volume ls"
|
||||
"docker stats --all --no-stream"
|
||||
"docker info"
|
||||
if [ $engine = 'docker' ]; then
|
||||
(command -v docker && systemctl is-active docker) || continue
|
||||
fi
|
||||
|
||||
if [ $engine == 'podman' ]; then
|
||||
command -v podman || continue
|
||||
fi
|
||||
|
||||
BASE_CONTAINER_EXTRA=/var/log/extra/${engine};
|
||||
mkdir -p $BASE_CONTAINER_EXTRA;
|
||||
ALL_FILE=$BASE_CONTAINER_EXTRA/${engine}_allinfo.log;
|
||||
|
||||
CONTAINER_INFO_CMDS=(
|
||||
"${engine} ps --all --size"
|
||||
"${engine} images"
|
||||
"${engine} stats --all --no-stream"
|
||||
"${engine} info"
|
||||
);
|
||||
for cmd in "${DOCKER_INFO_CMDS[@]}"; do
|
||||
if [ $engine = 'docker' ]; then
|
||||
CONTAINER_INFO_CMDS+=("${engine} volume ls")
|
||||
fi
|
||||
for cmd in "${CONTAINER_INFO_CMDS[@]}"; do
|
||||
echo "+ $cmd" >> $ALL_FILE;
|
||||
$cmd >> $ALL_FILE;
|
||||
done;
|
||||
|
||||
for cont in $(docker ps | awk {'print $NF'} | grep -v NAMES); do
|
||||
INFO_DIR=$BASE_DOCKER_EXTRA/containers/${cont};
|
||||
INFO_DIR=$BASE_CONTAINER_EXTRA/containers/${cont};
|
||||
mkdir -p $INFO_DIR;
|
||||
INFO_FILE=$INFO_DIR/docker_info.log;
|
||||
DOCKER_CONTAINER_INFO_CMDS=(
|
||||
"docker top $cont auxw"
|
||||
"docker exec $cont top -bwn1"
|
||||
"docker exec $cont yum list installed"
|
||||
"docker inspect $cont"
|
||||
CONTAINER_CONT_INFO_CMDS=(
|
||||
"${engine} top $cont auxw"
|
||||
"${engine} exec $cont top -bwn1"
|
||||
"${engine} exec $cont yum list installed"
|
||||
"${engine} inspect $cont"
|
||||
);
|
||||
for cmd in "${DOCKER_CONTAINER_INFO_CMDS[@]}"; do
|
||||
for cmd in "${CONTAINER_CONT_INFO_CMDS[@]}"; do
|
||||
echo "+ $cmd" >> $INFO_FILE;
|
||||
$cmd >> $INFO_FILE;
|
||||
done;
|
||||
docker logs $cont &> $INFO_DIR/stdout.log;
|
||||
docker cp $cont:/var/lib/kolla/config_files/config.json $INFO_DIR/config.json;
|
||||
${engine} logs $cont &> $INFO_DIR/stdout.log;
|
||||
${engine} cp $cont:/var/lib/kolla/config_files/config.json $INFO_DIR/config.json;
|
||||
# NOTE(flaper87): This should go away. Services should be
|
||||
# using a `logs` volume
|
||||
# NOTE(mandre) Do not copy logs if the containers is bind mounting /var/log directory
|
||||
if ! docker exec $cont stat $BASE_DOCKER_EXTRA 2>1 > /dev/null; then
|
||||
docker cp $cont:/var/log $INFO_DIR/log;
|
||||
if ! ${engine} exec $cont stat $BASE_CONTAINER_EXTRA 2>1 > /dev/null; then
|
||||
${engine} cp $cont:/var/log $INFO_DIR/log;
|
||||
fi;
|
||||
|
||||
# Delete symlinks because they break log collection and are generally
|
||||
|
@ -237,10 +254,12 @@
|
|||
find $INFO_DIR -type l -delete;
|
||||
done;
|
||||
|
||||
# NOTE(flaper87) Copy contents from the logs volume. We can expect this
|
||||
# volume to exist in a containerized environment.
|
||||
cp -r /var/lib/docker/volumes/logs/_data $BASE_DOCKER_EXTRA/logs;
|
||||
fi
|
||||
# NOTE(flaper87) Copy contents from the logs volume. We can expect this
|
||||
# volume to exist in a containerized environment.
|
||||
if [ $engine = 'docker' ]; then
|
||||
cp -r /var/lib/docker/volumes/logs/_data $BASE_CONTAINER_EXTRA/logs;
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Collect config-data
|
||||
shell: cp -r /var/lib/config-data/puppet-generated /var/log/config-data
|
||||
|
|
Loading…
Reference in New Issue