canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #05059
[Merge] ~andersson123/autopkgtest-cloud:update-sources-action-fix-traceback into autopkgtest-cloud:master
Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:update-sources-action-fix-traceback into autopkgtest-cloud:master.
Commit message:
fix: cloud: fix traceback in update-source juju action
Recently, there was an issue when trying to run:
juju run-action <cloud-worker-unit> update-sources
The following traceback occurred in
/var/log/juju/unit-autopkgtest-cloud-worker-X.log:
```
Traceback (most recent call last):¬
File "/var/lib/juju/agents/unit-autopkgtest-cloud-worker-0/charm/actions/update-sources", line 18, in <module>¬
pull(repo)¬
File "/var/lib/juju/agents/unit-autopkgtest-cloud-worker-0/charm/lib/utils.py", line 51, in pull¬
origin = [¬
IndexError: list index out of range
```
This was due to the `autopkgtest` repository on the cloud workers not
having a remote named "origin" - the remote is now called "salsa".
The pull function worked fine for autodep8.
This commit amends the issue by pulling a remote specified by this new
variable:
```
REPOSITORIES_REMOTES_MAP = {
AUTOPKGTEST_LOCATION: "salsa",
AUTODEP8_LOCATION: "origin",
}
```
Which is then laterally utilised in the update-sources action to pull
from the correct remote for each repository.
Requested reviews:
Canonical's Ubuntu QA (canonical-ubuntu-qa)
For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/470651
Quick fix for a traceback we encountered when trying to update the sources for autopkgtest and autodep8 in prod using:
juju run-action <cloud-worker-unit> update-sources
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:update-sources-action-fix-traceback into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/actions/update-sources b/charms/focal/autopkgtest-cloud-worker/actions/update-sources
index 7bd2f9d..43c8689 100755
--- a/charms/focal/autopkgtest-cloud-worker/actions/update-sources
+++ b/charms/focal/autopkgtest-cloud-worker/actions/update-sources
@@ -5,6 +5,7 @@ import sys
from reactive.autopkgtest_cloud_worker import (
AUTOPKGTEST_LOCATION,
AUTODEP8_LOCATION,
+ REPOSITORIES_REMOTES_MAP,
)
import pygit2
@@ -15,5 +16,5 @@ if __name__ == "__main__":
for location in [AUTOPKGTEST_LOCATION, AUTODEP8_LOCATION]:
repo = pygit2.Repository(location)
with UnixUser("ubuntu"):
- pull(repo)
+ pull(repo, REPOSITORIES_REMOTES_MAP[location])
install_autodep8(AUTODEP8_LOCATION)
diff --git a/charms/focal/autopkgtest-cloud-worker/lib/utils.py b/charms/focal/autopkgtest-cloud-worker/lib/utils.py
index 29ae3f4..66d1372 100644
--- a/charms/focal/autopkgtest-cloud-worker/lib/utils.py
+++ b/charms/focal/autopkgtest-cloud-worker/lib/utils.py
@@ -46,14 +46,14 @@ def install_autodep8(location):
subprocess.check_call(["make", "install"])
-def pull(repository):
+def pull(repository, remote_name):
"""This will do a sort of git fetch origin && git reset --hard origin/master"""
origin = [
- remote for remote in repository.remotes if remote.name == "origin"
+ remote for remote in repository.remotes if remote.name == remote_name
][0]
origin.fetch()
remote_master_id = repository.lookup_reference(
- "refs/remotes/origin/master"
+ f"refs/remotes/{remote_name}/master"
).target
repository.checkout_tree(repository.get(remote_master_id))
master_ref = repository.lookup_reference("refs/heads/master")
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 f2a8ab7..28251b6 100644
--- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
+++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
@@ -37,6 +37,11 @@ AUTOPKGTEST_PER_PACKAGE_LOCATION = os.path.expanduser(
"~ubuntu/autopkgtest-package-configs/"
)
+REPOSITORIES_REMOTES_MAP = {
+ AUTOPKGTEST_LOCATION: "salsa",
+ AUTODEP8_LOCATION: "origin",
+}
+
AUTOPKGTEST_CLONE_LOCATION = (
"https://salsa.debian.org/ubuntu-ci-team/autopkgtest.git"
)