Commit 51f45430 authored by Nicolas Wavrant's avatar Nicolas Wavrant

resilient: promises to check backup integrity shouldn't fail if proofs do no exist

parent 9aa1d2a6
...@@ -50,7 +50,7 @@ mode = 0644 ...@@ -50,7 +50,7 @@ mode = 0644
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/pbsready-import.cfg.in url = ${:_profile_base_location_}/pbsready-import.cfg.in
output = ${buildout:directory}/pbsready-import.cfg output = ${buildout:directory}/pbsready-import.cfg
md5sum = cdebc491a50a61fecc3391a5eb311bdb md5sum = 89619b0d8626c76402a11bb08e7ba8a1
mode = 0644 mode = 0644
[pbsready-export] [pbsready-export]
...@@ -66,7 +66,7 @@ mode = 0644 ...@@ -66,7 +66,7 @@ mode = 0644
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-pull-backup.cfg.in url = ${:_profile_base_location_}/instance-pull-backup.cfg.in
output = ${buildout:directory}/instance-pull-backup.cfg output = ${buildout:directory}/instance-pull-backup.cfg
md5sum = 232fcad0892e56d62f45e79ec01c7c3e md5sum = fba98fd740d564525fc3f236662f5d64
mode = 0644 mode = 0644
[template-replicated] [template-replicated]
......
...@@ -268,9 +268,17 @@ monitor-username = $${htpasswd:username} ...@@ -268,9 +268,17 @@ monitor-username = $${htpasswd:username}
[backup-transfer-integrity-promise] [backup-transfer-integrity-promise]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = inline: template = inline:
#!${dash:location}/bin/dash #!${dash:location}/bin/dash
cd $${directory:pbs-backup} # Raise an error if signatures are different
diff proof.signature $(find . -name backup.signature -maxdepth 2) # Error cannot be deduced if files do not exist
cd $${directory:pbs-backup}
if [ ! -f "proof.signature" ]; then exit 0; fi
backup_signature=$(find . -maxdepth 2 -name backup.signature)
if [ -z "$backup_signature" ]; then
exit 0;
else
diff "proof.signature" "$backup_signature";
fi
rendered = $${basedirectory:promises}/backup-transfer-integrity-promise rendered = $${basedirectory:promises}/backup-transfer-integrity-promise
mode = 700 mode = 700
......
...@@ -82,7 +82,17 @@ callback = $${post-notification-run:output} ...@@ -82,7 +82,17 @@ callback = $${post-notification-run:output}
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = inline: template = inline:
#!/${bash:location}/bin/bash #!/${bash:location}/bin/bash
if [ "$(wc -l $${post-notification-run:diff-file} | cut -d \ -f1)" -eq 0 ]; then exit 0; else exit 1; fi backup_diff_file=$${post-notification-run:diff-file}
if [ -f "$backup_diff_file" ]; then
if [ $(wc -l "$backup_diff_file" | cut -d \ -f1) -eq 0 ]; then
exit 0;
else
exit 1;
fi
else
# If file doesn't exist, promise should raise false positive
exit 0;
fi
rendered = $${basedirectory:promises}/backup-transfer-integrity-promise rendered = $${basedirectory:promises}/backup-transfer-integrity-promise
mode = 700 mode = 700
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment