Merge ~andersson123/autopkgtest-cloud:db-backup-add-checksum-to-filename into autopkgtest-cloud:master

Proposed by Tim Andersson
Status: Merged
Merged at revision: 752cfb13f8bf24d007ad04d3972e80f6e95c7de8
Proposed branch: ~andersson123/autopkgtest-cloud:db-backup-add-checksum-to-filename
Merge into: autopkgtest-cloud:master
Diff against target: 40 lines (+14/-1)
1 file modified
charms/focal/autopkgtest-web/webcontrol/db-backup (+14/-1)
Reviewer Review Type Date Requested Status
Brian Murray Approve
Skia Needs Fixing
Review via email: mp+462687@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

I don't know what workflow you have in mind here but I'd think it would be easier to have the checksum in the filename so that when you copy the item out of swift and put it on your local disk you have the checksum right there instead of having to look it up somewhere else.

Revision history for this message
Tim Andersson (andersson123) wrote :

Ah, I see what you mean, that makes more sense. I'll amend this MP.

Revision history for this message
Tim Andersson (andersson123) wrote :

Amended and ready for re-review

Revision history for this message
Skia (hyask) :
review: Needs Fixing
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) wrote :

This is amended and ready for re-review

Revision history for this message
Brian Murray (brian-murray) wrote :

Thanks for fixing that. Approved provided CI passes.

review: Approve
Revision history for this message
Tim Andersson (andersson123) wrote :

It looks like we're having issues with CI. I pushed this EOD yesterday ish. So it should've completed by now. I'll run LPCI locally and if it passes, I'll merge this.

Revision history for this message
Tim Andersson (andersson123) wrote :

LPCI passed on my machine, going to merge it, I've added a note on my todo list to look into CI weirdness

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/charms/focal/autopkgtest-web/webcontrol/db-backup b/charms/focal/autopkgtest-web/webcontrol/db-backup
index 4ca6a20..08b8513 100755
--- a/charms/focal/autopkgtest-web/webcontrol/db-backup
+++ b/charms/focal/autopkgtest-web/webcontrol/db-backup
@@ -8,6 +8,7 @@ import atexit
8import configparser8import configparser
9import datetime9import datetime
10import gzip10import gzip
11import hashlib
11import logging12import logging
12import os13import os
13import shutil14import shutil
@@ -96,6 +97,12 @@ def create_container_if_it_doesnt_exist(swift_conn: swiftclient.Connection):
96 )97 )
9798
9899
100def get_db_backup_checksum():
101 with open("%s.gz" % DB_BACKUP_PATH, "rb") as bkp_f:
102 md5 = hashlib.md5(bkp_f.read()).hexdigest()
103 return md5
104
105
99def upload_backup_to_db(106def upload_backup_to_db(
100 swift_conn: swiftclient.Connection,107 swift_conn: swiftclient.Connection,
101) -> swiftclient.Connection:108) -> swiftclient.Connection:
@@ -103,7 +110,13 @@ def upload_backup_to_db(
103 Upload compressed database to swift storage under container db-backups110 Upload compressed database to swift storage under container db-backups
104 """111 """
105 now = datetime.datetime.utcnow().strftime("%Y/%m/%d/%H_%M_%S")112 now = datetime.datetime.utcnow().strftime("%Y/%m/%d/%H_%M_%S")
106 object_path = "%s/%s" % (now, DB_PATH.name + ".gz")113 checksum = get_db_backup_checksum()
114 object_path = "%s/%s-%s.%s" % (
115 now,
116 DB_PATH.name.split(".")[0],
117 checksum,
118 "db.gz",
119 )
107 for retry in range(SWIFT_RETRIES):120 for retry in range(SWIFT_RETRIES):
108 try:121 try:
109 swift_conn.put_object(122 swift_conn.put_object(

Subscribers

People subscribed via source and target branches