From bd45571bebdae96b04a4cefa935fe57f11f1b2e5 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 22 May 2014 11:16:33 +1000 Subject: [PATCH] Only copy symlink name of logs devstack creates a shortened symlink without timestamp (foo.log -> foo.2014-01-01-000000.log) for each log to latest log. Thus we just copy the symlinks to avoid excessively long file-names. This removes the need to remove duplicate log files, which was incorrectly removing grenade.sh.log (because it has multiple '.'s and kind of looks like the time-stampped log files) The grenade log cleanup is added in a separate section. In general, it should be better to clean-up logs in a more specific fashion like this to avoid the situtation where a glob match removes things we really want. Also, there is no $BASE/new/devstacklog.txt. The devstack upgrade process is driven by grenade.sh which calls parts of devstack directly; so all relevant log output goes into grenade.sh.log Change-Id: Ib1c4476c28c5c032ed9ab1682118a4f4528db450 --- functions.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/functions.sh b/functions.sh index 4e4e1f76..88b68d40 100644 --- a/functions.sh +++ b/functions.sh @@ -441,9 +441,15 @@ function cleanup_host { fi done + # copy devstack log files if [ -d $BASE/old ]; then sudo mkdir -p $BASE/logs/old $BASE/logs/new $BASE/logs/grenade - sudo cp $BASE/old/screen-logs/* $BASE/logs/old/ + # copy all log files, but note that devstack creates a shortened + # symlink without timestamp (foo.log -> foo.2014-01-01-000000.log) + # for each log to latest log. Thus we just copy the symlinks to + # avoid excessively long file-names. + find $BASE/old/screen-logs -type l -print0 | \ + xargs -0 -I {} sudo cp {} $BASE/logs/old sudo cp $BASE/old/devstacklog.txt $BASE/logs/old/ sudo cp $BASE/old/devstack/localrc $BASE/logs/old/localrc.txt sudo cp $BASE/old/tempest/etc/tempest.conf $BASE/logs/old/tempest_conf.txt @@ -452,10 +458,15 @@ function cleanup_host { else NEWLOGTARGET=$BASE/logs fi - sudo cp $BASE/new/screen-logs/* $NEWLOGTARGET/ - sudo cp $BASE/new/devstacklog.txt $NEWLOGTARGET/ + find $BASE/new/screen-logs -type l -print0 | \ + xargs -0 -I {} sudo cp {} $NEWLOGTARGET/ sudo cp $BASE/new/devstack/localrc $NEWLOGTARGET/localrc.txt + # $BASE/logs is a link to $WORKSPACE (see + # devstack-vm-gate-wrap.sh) so we need to clear out a few extra + # logs files we don't want to keep + sudo rm $BASE/logs/grenade.sh.log.* + # Copy tempest config file sudo cp $BASE/new/tempest/etc/tempest.conf $NEWLOGTARGET/tempest_conf.txt @@ -520,13 +531,6 @@ function cleanup_host { find $BASE/logs/rabbitmq -type f -exec mv '{}' '{}'.txt \; fi - # Remove duplicate logs - sudo rm $BASE/logs/*.*.txt - if [ -d $BASE/old ]; then - sudo rm $BASE/logs/old/*.*.txt - sudo rm $BASE/logs/new/*.*.txt - fi - # Compress all text logs sudo find $BASE/logs -iname '*.txt' -execdir gzip -9 {} \+ sudo find $BASE/logs -iname '*.dat' -execdir gzip -9 {} \+