Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:worker-upstream-percentage into autopkgtest-cloud:master.
Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/464318 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:worker-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 5689302..695e068 100755 --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker @@ -1487,9 +1487,21 @@ def amqp_connect(cfg, callback): contexts = ["", "huge-", "ppa-"] + try: + worker_upstream_percentage = int( + cfg.get("autopkgtest", "worker_upstream_percentage") + ) + # catch NoOption, NoSection incase something wrong with config file + # catch ValueError if int casting unsuccessful + except ( + configparser.NoOptionError, + configparser.NoSectionError, + ValueError, + ) as _: + worker_upstream_percentage = 50 # crude way to not allow upstream tests to monopolise resources - only 50% # of workers will take them - if random.randint(1, 100) < 50: + if random.randint(1, 100) < worker_upstream_percentage: contexts += ["upstream-"] for release in cfg.get("autopkgtest", "releases").split(): diff --git a/charms/focal/autopkgtest-cloud-worker/config.yaml b/charms/focal/autopkgtest-cloud-worker/config.yaml index e7bbfba..8780bbe 100644 --- a/charms/focal/autopkgtest-cloud-worker/config.yaml +++ b/charms/focal/autopkgtest-cloud-worker/config.yaml @@ -114,3 +114,8 @@ options: default: "" description: config for periodic cleanup of /tmp directory type: string + worker-upstream-percentage: + default: 50 + description: Percentage of workers that'll accept upstream tests. + This is useful to prioritise certain tests. + type: int diff --git a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py index 38b6c7a..f94b03b 100644 --- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py +++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py @@ -500,6 +500,7 @@ def write_swift_config(): "config.changed.lxd-remotes", "config.changed.mirror", "config.changed.net-name", + "config.changed.worker-upstream-percentage", ) @when_any("config.set.nova-rcs", "config.set.lxd-remotes") def write_worker_config(): @@ -524,6 +525,9 @@ def write_worker_config(): "setup_command": config().get("worker-setup-command"), "setup_command2": config().get("worker-setup-command2"), "per_package_config_dir": AUTOPKGTEST_PER_PACKAGE_LOCATION, + "worker_upstream_percentage": config().get( + "worker-upstream-percentage" + ), }, "virt": { "package_size_default": config().get("worker-default-flavor"), @@ -543,7 +547,8 @@ def write_worker_config(): for k in replacements: # pylint: disable=consider-using-dict-items if replacements[k]: - s = s.replace(k, replacements[k]) + if isinstance(s, str): + s = s.replace(k, replacements[k]) return s diff --git a/mojo/service-bundle b/mojo/service-bundle index f2da41c..315e045 100644 --- a/mojo/service-bundle +++ b/mojo/service-bundle @@ -75,6 +75,7 @@ applications: <<: *common-options nova-rcs: include-base64://{{local_dir}}/novarcs.tar worker-tmp-cleanup-config: D /tmp 1777 root root 30d + worker-upstream-percentage: 50 {%- if stage_name == "production" %} net-name: net_prod-proposed-migration worker-default-flavor: autopkgtest
-- 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