← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~hyask/autopkgtest-cloud:skia/fix_upstream_percentage into autopkgtest-cloud:master

 

Skia has proposed merging ~hyask/autopkgtest-cloud:skia/fix_upstream_percentage into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)
Related bugs:
  Bug #2062537 in Auto Package Testing: "Change the way upstream jobs percentage is done"
  https://bugs.launchpad.net/auto-package-testing/+bug/2062537

For more details, see:
https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/464721

Fixes https://bugs.launchpad.net/auto-package-testing/+bug/2062537
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/fix_upstream_percentage into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
index bfa35e7..53fa05b 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
@@ -650,6 +650,19 @@ def request(msg):
     systemd_logging_handler._extra["ADT_RELEASE"] = release
     systemd_logging_handler._extra["ADT_ARCH"] = architecture
 
+    if "-upstream-" in msg.delivery_info["routing_key"]:
+        # crude way to not allow upstream tests to monopolise resources - only 20%
+        # of chances to really run them
+        if random.randint(1, 100) > 20:
+            logging.info(
+                "Upstream job detected and dice rolled above 20, skipping for now"
+            )
+            return
+        else:
+            logging.info(
+                "Upstream job detected and dice rolled below 20, running it now"
+            )
+
     body = msg.body
     if isinstance(body, bytes):
         try:
@@ -1475,12 +1488,7 @@ def amqp_connect(cfg, callback):
     # avoid preferring the same architecture on all workers
     queues = []
 
-    contexts = ["", "huge-", "ppa-"]
-
-    # crude way to not allow upstream tests to monopolise resources - only 50%
-    # of workers will take them
-    if random.randint(1, 100) < 50:
-        contexts += ["upstream-"]
+    contexts = ["", "huge-", "ppa-", "upstream-"]
 
     for release in cfg.get("autopkgtest", "releases").split():
         for context in contexts: