From 39945d5630c0d83a8b7fafd6b45e945c3e89c800 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 29 Jun 2020 12:50:43 -0600 Subject: [PATCH] Exclude /etc/hostname Similar to the previous patch where we excluded /etc/hosts, it turns out that /etc/hostname is also a special file that cannot be synced in via kolla because they are bindmounted internally. https://github.com/containers/libpod/blob/6ac009d5304127f6758be157c7302646e5a481e5/libpod/container_internal_linux.go#L1236 Additionally this change includes cleanup for end users who may have hit LP#1860607 and allows folks who have hit this to just simply rerun the deployment and not have to manually cleanup the synced files. Change-Id: I84287d9c1ef110511c66743f9a3a22709077b0cb Closes-Bug: #1885619 (cherry picked from commit 777920dfba58fa7b26c063fa5d6df0203009d12c) --- common/container-puppet.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/common/container-puppet.sh b/common/container-puppet.sh index 3e5328e3ce..c7d5a289e0 100644 --- a/common/container-puppet.sh +++ b/common/container-puppet.sh @@ -101,7 +101,7 @@ if [ -z "$NO_ARCHIVE" ]; then ro_files="/etc/puppet/ /etc/puppetlabs/ /opt/puppetlabs/ /etc/pki/ca-trust/extracted " ro_files+="/etc/pki/ca-trust/source/anchors /etc/pki/tls/certs/ca-bundle.crt " ro_files+="/etc/pki/tls/certs/ca-bundle.trust.crt /etc/pki/tls/cert.pem " - ro_files+="/etc/hosts /etc/localtime" + ro_files+="/etc/hosts /etc/localtime /etc/hostname" for ro in $ro_files; do if [ -e "$ro" ]; then exclude_files+=" --exclude=$ro" @@ -118,7 +118,6 @@ if [ -z "$NO_ARCHIVE" ]; then echo "Rsyncing config files from ${rsync_srcs} into ${conf_data_path}" rsync -a $verbosity -R --delay-updates --delete-after $exclude_files $rsync_srcs ${conf_data_path} - # Also make a copy of files modified during puppet run echo "Gathering files modified after $(stat -c '%y' $origin_of_time)" @@ -139,6 +138,16 @@ if [ -z "$NO_ARCHIVE" ]; then rsync -a $verbosity -R -0 --delay-updates --delete-after $exclude_files \ --files-from=$TMPFILE2 / ${puppet_generated_path} + # Cleanup any special files that might have been copied into place + # previously because fixes for LP#1860607 did not cleanup and required + # manual intervention if a container hit this. We can safely remove these + # files because they should be bind mounted into containers + for ro in $ro_files; do + if [ -e "${puppet_generated_path}/${ro}" ]; then + rm -rf "${puppet_generated_path}/${ro}" + fi + done + # Write a checksum of the config-data dir, this is used as a # salt to trigger container restart when the config changes # note: while being excluded from the output, password files