Merge ~andersson123/autopkgtest-cloud:no-double-download-results into autopkgtest-cloud:master

Proposed by Tim Andersson
Status: Needs review
Proposed branch: ~andersson123/autopkgtest-cloud:no-double-download-results
Merge into: autopkgtest-cloud:master
Diff against target: 29 lines (+6/-1)
2 files modified
charms/focal/autopkgtest-web/webcontrol/download-results (+5/-0)
charms/focal/autopkgtest-web/webcontrol/helpers/utils.py (+1/-1)
Reviewer Review Type Date Requested Status
Canonical's Ubuntu QA Pending
Review via email: mp+465054@code.launchpad.net
To post a comment you must log in.
b06c91b... by Tim Andersson

fix: web: add UNIQUE constraint to uuid column creation in helpers/utils.py `init_db`

Whilst this doesn't fix the issue of two "write requests" going into
the sqlite-writer queue, this commit would still mean we get no
duplicate results.

Even in the case of two duplicate queue message, this commit would just
ensure that the original entry is just replaced with the duplicate
entry.

Unmerged commits

78b2b4d... by Tim Andersson

fix: web: add hacky fix for download-results to stop duplicate results

Succeeded
[SUCCEEDED] pre_commit:0 (build)
[SUCCEEDED] unit_tests:0 (build)
[SUCCEEDED] build_charms:0 (build)
13 of 3 results
b06c91b... by Tim Andersson

fix: web: add UNIQUE constraint to uuid column creation in helpers/utils.py `init_db`

Whilst this doesn't fix the issue of two "write requests" going into
the sqlite-writer queue, this commit would still mean we get no
duplicate results.

Even in the case of two duplicate queue message, this commit would just
ensure that the original entry is just replaced with the duplicate
entry.

Succeeded
[SUCCEEDED] pre_commit:0 (build)
[SUCCEEDED] unit_tests:0 (build)
[SUCCEEDED] build_charms:0 (build)
13 of 3 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charms/focal/autopkgtest-web/webcontrol/download-results b/charms/focal/autopkgtest-web/webcontrol/download-results
2index 1297a66..5cae5dc 100755
3--- a/charms/focal/autopkgtest-web/webcontrol/download-results
4+++ b/charms/focal/autopkgtest-web/webcontrol/download-results
5@@ -122,6 +122,11 @@ if __name__ == "__main__":
6 logging.basicConfig(
7 level=("DEBUG" in os.environ and logging.DEBUG or logging.INFO)
8 )
9+ # FIXME: Hacky interrim solution to fix synchronisation issues
10+ if os.path.exists("/run/autopkgtest-web-is-leader"):
11+ logging.info("Unit is not leader, exiting...")
12+ time.sleep(300)
13+ sys.exit(0)
14
15 amqp_con = amqp_connect()
16 status_ch = amqp_con.channel()
17diff --git a/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py b/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py
18index 4e26eb8..11b9774 100644
19--- a/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py
20+++ b/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py
21@@ -123,7 +123,7 @@ def init_db(path, **kwargs):
22 " exitcode INTEGER, "
23 " requester TEXT, "
24 " env TEXT, "
25- " uuid TEXT, "
26+ " uuid TEXT UNIQUE, "
27 " PRIMARY KEY(test_id, run_id), "
28 " FOREIGN KEY(test_id) REFERENCES test(id))"
29 )

Subscribers

People subscribed via source and target branches