From 746d98d9627bdf3146f4ce2b99cf968a93a592f6 Mon Sep 17 00:00:00 2001
From: Alain Takoudjou <alain.takoudjou@nexedi.com>
Date: Fri, 5 Oct 2018 12:01:13 +0200
Subject: [PATCH] slaprunner: exclude backup.signature while checking if file
 changed during export

Runner exporter failed with this message while checking if file changed during backup of instances files:

    < 3226bab4cd318d30cfbde18e6530435dcae3205f94103384ce266c3c73d1afeb  ./runner/instance/slappart2/srv/backup/pbs/slaprunner-slappart1-runner-1/backup.signature
    < 3226bab4cd318d30cfbde18e6530435dcae3205f94103384ce266c3c73d1afeb  ./runner/instance/slappart3/srv/backup/runner/backup.signature
    < 3226bab4cd318d30cfbde18e6530435dcae3205f94103384ce266c3c73d1afeb  ./runner/instance/slappart5/srv/backup/runner/backup.signature
    5248d5244
    < bb3d96876d1d6cecee9878d835e7515215fc5d2a6ae6b647d0e7915c36700b54  ./runner/instance/slappart4/srv/backup/runner/backup.signature
    ERROR: Some backups are not consistent, exporter should be re-run.

This is because instance in webrunner has also backup.signature the file is excluded while doing sha256sum on backup file:

    find -type f ! -name backup.signature -print0 | xargs -0 sha256sum | sort -k 66 > backup.signature

A fix is to exclude backup.signature in `find`.
---
 software/slaprunner/buildout.hash.cfg                | 2 +-
 software/slaprunner/template/runner-export.sh.jinja2 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/software/slaprunner/buildout.hash.cfg b/software/slaprunner/buildout.hash.cfg
index 3a8ff47fe..d977a9d7d 100644
--- a/software/slaprunner/buildout.hash.cfg
+++ b/software/slaprunner/buildout.hash.cfg
@@ -30,7 +30,7 @@ md5sum = 7a879739afe55320ee96409bcc8a52ab
 
 [template-runner-export-script]
 filename = template/runner-export.sh.jinja2
-md5sum = be47acbe610305982168cff6a9eeb9ec
+md5sum = 231f9b74862f8991f54326511e76f5ec
 
 [instance-runner-export]
 filename = instance-runner-export.cfg.in
diff --git a/software/slaprunner/template/runner-export.sh.jinja2 b/software/slaprunner/template/runner-export.sh.jinja2
index 96a7f29ab..fe7851f14 100644
--- a/software/slaprunner/template/runner-export.sh.jinja2
+++ b/software/slaprunner/template/runner-export.sh.jinja2
@@ -122,7 +122,7 @@ sleep 5
 
 # Getting files from runner backup directory, as instance backup files may be
 # explicitely excluded from the backup, using the srv/exporter.exclude
-find -path "./runner/instance/slappart*/srv/backup/*" -type f -print0 |
+find -path "./runner/instance/slappart*/srv/backup/*" -type f ! -name backup.signature -print0 |
 xargs -r0 sha256sum | sort -k 66 > "$tmp_backup_sum"
 
 # If no backup found, it's over
-- 
2.30.9