From 9b6a631a4d2b3e97cfe6e4b36ff1cab49680ed1c Mon Sep 17 00:00:00 2001 From: Nicolas Wavrant <nicolas.wavrant@nexedi.com> Date: Thu, 13 Oct 2016 15:54:13 +0200 Subject: [PATCH] resilient: makes promises more understandable --- stack/resilient/buildout.cfg | 4 ++-- stack/resilient/instance-pull-backup.cfg.in | 14 ++++++++++---- stack/resilient/pbsready-import.cfg.in | 8 ++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/stack/resilient/buildout.cfg b/stack/resilient/buildout.cfg index 0969aa057..6a40ea0da 100644 --- a/stack/resilient/buildout.cfg +++ b/stack/resilient/buildout.cfg @@ -50,7 +50,7 @@ mode = 0644 recipe = slapos.recipe.template url = ${:_profile_base_location_}/pbsready-import.cfg.in output = ${buildout:directory}/pbsready-import.cfg -md5sum = a13be3bd76d6a52b6527c7035ba33a06 +md5sum = 10264fe1cfb7ebe567d50ebabbd93a43 mode = 0644 [pbsready-export] @@ -66,7 +66,7 @@ mode = 0644 recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-pull-backup.cfg.in output = ${buildout:directory}/instance-pull-backup.cfg -md5sum = 3892f86fcf850511dc0e6e4983b1961a +md5sum = 3ef8f98ff013f06fcd81bba18872e561 mode = 0644 [template-replicated] diff --git a/stack/resilient/instance-pull-backup.cfg.in b/stack/resilient/instance-pull-backup.cfg.in index 6b6ef7ce9..810b569d4 100644 --- a/stack/resilient/instance-pull-backup.cfg.in +++ b/stack/resilient/instance-pull-backup.cfg.in @@ -8,7 +8,7 @@ parts = cron-entry-logrotate pbs-sshkeys-authority sshkeys-openssh - backup-transfer-integrity-promise + backup-checksum-integrity-promise resilient-genstatrss-wrapper pbs-push-history-log backup-signature-link @@ -264,7 +264,7 @@ monitor-username = $${htpasswd:username} #-- #-- Resiliency promises. -[backup-transfer-integrity-promise] +[backup-checksum-integrity-promise] recipe = slapos.recipe.template:jinja2 template = inline: #!${dash:location}/bin/dash @@ -276,9 +276,15 @@ template = inline: if [ -z "$backup_signature" ]; then exit 0; else - diff "proof.signature" "$backup_signature"; + diff -q "proof.signature" "$backup_signature"; + if [ "$?" -eq 0 ]; then + exit 0; + else + echo "Signature file is not the same before and after transfer" + exit 1 + fi fi -rendered = $${basedirectory:promises}/backup-transfer-integrity-promise +rendered = $${basedirectory:promises}/backup-checksum-integrity mode = 700 [resilient-genstatrss-wrapper] diff --git a/stack/resilient/pbsready-import.cfg.in b/stack/resilient/pbsready-import.cfg.in index 746ada372..67c317003 100644 --- a/stack/resilient/pbsready-import.cfg.in +++ b/stack/resilient/pbsready-import.cfg.in @@ -26,7 +26,7 @@ parts = check-backup-integrity-on-notification import-on-notification - backup-transfer-integrity-promise + backup-checksum-integrity-promise resilient-publish-connection-parameter backup-signature-link @@ -78,7 +78,7 @@ recipe = slapos.cookbook:notifier.callback on-notification-id = $${slap-parameter:on-notification} callback = $${post-notification-run:output} -[backup-transfer-integrity-promise] +[backup-checksum-integrity-promise] recipe = slapos.recipe.template:jinja2 template = inline: #!/${bash:location}/bin/bash @@ -90,10 +90,10 @@ template = inline: exit 1; fi else - # If file doesn't exist, promise should raise false positive + # If file doesn't exist, promise shouldnt raise false positive exit 0; fi -rendered = $${basedirectory:promises}/backup-transfer-integrity-promise +rendered = $${basedirectory:promises}/backup-checksum-integrity mode = 700 ########### -- 2.30.9