Skia has proposed merging ~hyask/autopkgtest-cloud:skia/db_checksum into autopkgtest-cloud:master.
Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/464898 This allows Britney to checksum the database instead of relying on Content-Length. -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/db_checksum into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py index 1cc391d..994a91a 100644 --- a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py +++ b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py @@ -456,6 +456,12 @@ def symlink_public_db(): charm_dir(), "webcontrol", "static", "autopkgtest.db" ), ) + os.symlink( + os.path.join(publicdir, "autopkgtest.db.sha256"), + os.path.join( + charm_dir(), "webcontrol", "static", "autopkgtest.db.sha256" + ), + ) status.maintenance("Done creating symlink for public database") set_flag("autopkgtest-web.public-db-symlinked") except FileExistsError: diff --git a/charms/focal/autopkgtest-web/webcontrol/publish-db b/charms/focal/autopkgtest-web/webcontrol/publish-db index 8db561d..b4d9c41 100755 --- a/charms/focal/autopkgtest-web/webcontrol/publish-db +++ b/charms/focal/autopkgtest-web/webcontrol/publish-db @@ -7,6 +7,7 @@ external monitoring tools. """ import gzip +import hashlib import logging import os import sqlite3 @@ -191,6 +192,8 @@ if __name__ == "__main__": target = config["web"]["database_ro"] target_new = "{}.new".format(target) + target_checksum = "{}.sha256".format(target) + target_checksum_new = "{}.new".format(target_checksum) try: # systemd makes sure to not run us in parallel, so we can safely @@ -205,4 +208,9 @@ if __name__ == "__main__": db_con.commit() db_con.close() + checksum = hashlib.sha256(open(target_new, "rb").read()).hexdigest() + with open(target_checksum_new, "w") as f: + f.write(checksum) + + os.rename(target_checksum_new, target_checksum) os.rename(target_new, target) diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-home.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-home.html index fe51858..1721c84 100644 --- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-home.html +++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-home.html @@ -37,7 +37,7 @@ <div class="panel-heading">Machine readable data</div> <div class="panel-body"> <ul> - <li><a href="{{base_url}}static/autopkgtest.db">SQLite database with results</a></li> + <li><a href="{{base_url}}static/autopkgtest.db">SQLite database with results</a> (<a href="{{base_url}}static/autopkgtest.db.sha256">sha256</a>)</li> <li><a href="{{base_url}}static/running.json">Currently running tests in JSON format</a></li> <li><a href="{{base_url}}queues.json">Queued tests in JSON format</a></li> </ul>
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp