← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:lxd-metrics-update into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:lxd-metrics-update 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/460195
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:lxd-metrics-update into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics
index 7224dd3..75288c6 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/metrics
@@ -9,6 +9,8 @@ from influxdb import InfluxDBClient
 
 SYSTEM_BUS = Gio.bus_get_sync(Gio.BusType.SYSTEM)
 
+LXC_LIST_OF_REMOTES = "/home/ubuntu/lxd-remotes"
+
 INFLUXDB_CONTEXT = os.environ["INFLUXDB_CONTEXT"]
 INFLUXDB_DATABASE = os.environ["INFLUXDB_DATABASE"]
 INFLUXDB_HOSTNAME = os.environ["INFLUXDB_HOSTNAME"]
@@ -99,16 +101,33 @@ def get_units():
     return make_submission(counts, "autopkgtest_unit_status")
 
 
+def get_list_of_intended_remote_ips():
+    if os.path.isfile(LXC_LIST_OF_REMOTES):
+        with open(LXC_LIST_OF_REMOTES, "r") as f:
+            remotes = f.read()
+        remotes = remotes.splitlines()
+        ips = []
+        for remote in remotes:
+            if "lxd-armhf" not in remote:
+                continue
+            ips.append(remote.split(":")[0].rstrip())
+        return ips
+    return None
+
+
 def get_remotes():
     cluster_counts = {}
     noncluster_counts = {}
     out = subprocess.check_output(
         ["lxc", "remote", "list", "--format=json"], universal_newlines=True
     )
+    intended_ips = get_list_of_intended_remote_ips()
 
     for r in json.loads(out):
         if not r.startswith("lxd"):
             continue
+        if intended_ips is not None and r.replace("lxd-armhf-", "") not in intended_ips:
+            continue
 
         (_, arch, _) = r.split("-", 3)
         (cluster_active, cluster_error) = cluster_counts.setdefault(
diff --git a/mojo/lxd-remotes b/mojo/lxd-remotes
new file mode 100755
index 0000000..a6db9d7
--- /dev/null
+++ b/mojo/lxd-remotes
@@ -0,0 +1,11 @@
+#!/usr/bin/bash
+
+remotes=$(juju config autopkgtest-lxd-worker lxd-remotes)
+
+units=$(juju status --format=json autopkgtest-lxd-worker | jq --monochrome-output --raw-output '.applications["autopkgtest-lxd-worker"].units | keys[]')
+
+printf "%s" "${remotes}" | tee /tmp/lxd-remotes
+
+for unit in $units; do
+    juju scp /tmp/lxd-remotes "${unit}":/home/ubuntu/
+done
diff --git a/mojo/manifest b/mojo/manifest
index 2c2b6d6..6b4f55a 100644
--- a/mojo/manifest
+++ b/mojo/manifest
@@ -2,5 +2,6 @@ collect
 secrets
 bundle config=service-bundle wait=True max-wait=1200
 script config=make-lxd-secgroup
+script config=lxd-remotes
 script config=postdeploy
 script config=rabbitmq-cleanup-setup

Follow ups