From a9da92498ffb6b3759cf79b82c2ad82a28c4ed22 Mon Sep 17 00:00:00 2001 From: charlie4284 Date: Wed, 11 Feb 2026 15:15:20 +0800 Subject: [PATCH 1/4] feat: otel-collector snap --- .../github_runner_image_builder/templates/cloud-init.sh.j2 | 6 ++++++ app/tests/integration/commands.py | 7 +++++++ app/tests/unit/test_openstack_builder.py | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 b/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 index 1f905ee9..3803234f 100644 --- a/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 +++ b/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 @@ -120,6 +120,12 @@ function install_yq() { /usr/bin/snap remove go } +function install_opentelemetry_collector_snap() { + echo "Installing OpenTelemetry Collector snap" + /usr/bin/sudo snap install opentelemetry-collector + /usr/bin/sudo snap disable opentelemetry-collector +} + function install_github_runner() { version="$1" arch="$2" diff --git a/app/tests/integration/commands.py b/app/tests/integration/commands.py index e7d3e740..112f9b82 100644 --- a/app/tests/integration/commands.py +++ b/app/tests/integration/commands.py @@ -38,6 +38,13 @@ class Commands: name="check aproxy", command="sudo snap info aproxy && sudo snap services aproxy", ), + Commands( + name="check opentelemetry-collector snap installed and inactive", + command=( + "sudo snap services opentelemetry-collector | grep -q 'disabled' " + "&& sudo snap services opentelemetry-collector | grep -q 'inactive'" + ), + ), Commands(name="update apt in docker", command="docker run python:3.10-slim apt-get update"), Commands(name="docker version", command="docker version"), Commands(name="check python3 alias", command="python --version"), diff --git a/app/tests/unit/test_openstack_builder.py b/app/tests/unit/test_openstack_builder.py index 33099b40..ca009200 100644 --- a/app/tests/unit/test_openstack_builder.py +++ b/app/tests/unit/test_openstack_builder.py @@ -831,6 +831,12 @@ def test__generate_cloud_init_script( /usr/bin/snap remove go }} +function install_opentelemetry_collector_snap() {{ + echo "Installing OpenTelemetry Collector snap" + /usr/bin/sudo snap install opentelemetry-collector + /usr/bin/sudo snap disable opentelemetry-collector +}} + function install_github_runner() {{ version="$1" arch="$2" From 4ba85e2dfd3b0d504b8474aec7addac95e2295e7 Mon Sep 17 00:00:00 2001 From: charlie4284 Date: Wed, 11 Feb 2026 15:24:47 +0800 Subject: [PATCH 2/4] chore: application bump related changes --- app/pyproject.toml | 4 ++-- docs/changelog.md | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/pyproject.toml b/app/pyproject.toml index 386db293..1deff3ce 100644 --- a/app/pyproject.toml +++ b/app/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "github-runner-image-builder" -version = "0.12.0" +version = "0.13.0" authors = [ { name = "Canonical IS DevOps", email = "is-devops-team@canonical.com" }, ] @@ -32,7 +32,7 @@ dependencies = { file = ["requirements.txt"] } [tool.pydocstyle] match = "src/github_runner_image_builder/cli.py" -ignore = ["D301"] # ignore backshlashes in docstring - click lib uses them. +ignore = ["D301"] # ignore backshlashes in docstring - click lib uses them. [tool.bandit] diff --git a/docs/changelog.md b/docs/changelog.md index 603312f4..8d00d65c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,9 @@ +## [#195 feat: otel-collector snap](https://github.com/canonical/github-runner-image-builder-operator/pull/195) (2026-02-11) +* Install opentelemetry collector snap in the runner image. + ## [#172 feat: apt upgrade](https://github.com/canonical/github-runner-image-builder-operator/pull/172) (2025-11-26) * Apply apt-update and apt-upgrade to GH runner images by applying them during cloud-init. From aac876910f22c4e200f01c98e127e7c258b33453 Mon Sep 17 00:00:00 2001 From: charlie4284 Date: Fri, 13 Feb 2026 02:54:01 +0000 Subject: [PATCH 3/4] fix: call installation func --- app/src/github_runner_image_builder/templates/cloud-init.sh.j2 | 1 + app/tests/unit/test_openstack_builder.py | 1 + 2 files changed, 2 insertions(+) diff --git a/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 b/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 index 3803234f..ff57b0f1 100644 --- a/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 +++ b/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 @@ -178,6 +178,7 @@ if [ $RELEASE != "focal" ]; then install_yarn fi install_yq +install_opentelemetry_collector_snap install_github_runner "$github_runner_version" "$github_runner_arch" chown_home configure_system_users diff --git a/app/tests/unit/test_openstack_builder.py b/app/tests/unit/test_openstack_builder.py index ca009200..913cb20e 100644 --- a/app/tests/unit/test_openstack_builder.py +++ b/app/tests/unit/test_openstack_builder.py @@ -890,6 +890,7 @@ def test__generate_cloud_init_script( install_yarn fi install_yq +install_opentelemetry_collector_snap install_github_runner "$github_runner_version" "$github_runner_arch" chown_home configure_system_users\ From b1f7f737e259c5be0b56ef1630f75733dad9fd83 Mon Sep 17 00:00:00 2001 From: charlie4284 Date: Fri, 13 Feb 2026 07:39:18 +0000 Subject: [PATCH 4/4] chore: explicit stable flag for snap channel --- app/src/github_runner_image_builder/templates/cloud-init.sh.j2 | 2 +- app/tests/unit/test_openstack_builder.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 b/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 index ff57b0f1..f13fe4b4 100644 --- a/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 +++ b/app/src/github_runner_image_builder/templates/cloud-init.sh.j2 @@ -122,7 +122,7 @@ function install_yq() { function install_opentelemetry_collector_snap() { echo "Installing OpenTelemetry Collector snap" - /usr/bin/sudo snap install opentelemetry-collector + /usr/bin/sudo snap install opentelemetry-collector --stable /usr/bin/sudo snap disable opentelemetry-collector } diff --git a/app/tests/unit/test_openstack_builder.py b/app/tests/unit/test_openstack_builder.py index 913cb20e..2a1278e2 100644 --- a/app/tests/unit/test_openstack_builder.py +++ b/app/tests/unit/test_openstack_builder.py @@ -833,7 +833,7 @@ def test__generate_cloud_init_script( function install_opentelemetry_collector_snap() {{ echo "Installing OpenTelemetry Collector snap" - /usr/bin/sudo snap install opentelemetry-collector + /usr/bin/sudo snap install opentelemetry-collector --stable /usr/bin/sudo snap disable opentelemetry-collector }}