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 55f0bb1ad8b204f1dfc8ade159876fadad9f4c68 Mon Sep 17 00:00:00 2001 From: charlie4284 Date: Fri, 13 Feb 2026 05:39:46 +0000 Subject: [PATCH 4/4] fix: vale errors --- CONTRIBUTING.md | 12 ++++++------ Makefile.docs | 13 +++++++++---- README.md | 2 +- docs/changelog.md | 4 ++-- docs/how-to/configure-build-interval.md | 2 +- docs/index.md | 2 +- docs/reference/charm-architecture.md | 14 +++++++------- docs/tutorial/quick-start.md | 2 +- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d96cfa47..f368de18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,16 +18,16 @@ that can be used for linting and formatting code when you're preparing contribut ```shell -tox run -e format # update your code according to linting rules -tox run -e lint # code style -tox run -e unit # unit tests -tox run -e integration # integration tests -tox # runs 'format', 'lint', and 'unit' environments +tox run -e format +tox run -e lint +tox run -e unit +tox run -e integration +tox ``` The integration tests (both of the charm and the app) -require options to be passed via the command line (see `tests/conftest.py`) and +require options to be passed through the command line (see `tests/conftest.py`) and environment variables `OPENSTACK_PASSWORD` to be able to deploy the charm and/or upload images to OpenStack. ## Build the charm diff --git a/Makefile.docs b/Makefile.docs index c4b2cb5b..bbc5613f 100644 --- a/Makefile.docs +++ b/Makefile.docs @@ -36,8 +36,9 @@ endif .PHONY: .check-lychee .check-lychee: ifndef HAS_LYCHEE - $(call errmsg,'lychee' is not installed. Please install it first) \ - exit 1; + $(call msg,--- 'lychee' not installed; skipping link check ---) +else + @true endif @@ -60,9 +61,13 @@ vale: .check-vale vale-sync ## Run Vale checks on docs # ============================================================================== .PHONY: lychee -lychee: .check-lychee ## Run Lychee checks on docs - $(call msg,--- Running lychee checks on "$(LYCHEE_DOCS_FILES)"... ---) +lychee: ## Run Lychee checks on docs +ifeq ($(HAS_LYCHEE),) + $(call msg,--- 'lychee' not installed; skipping link check ---) +else + $(call msg,--- Running lychee checks on "$(DOCS_FILES)"... ---) @lychee $(DOCS_FILES) +endif # ============================================================================== # Helper Targets diff --git a/README.md b/README.md index 094b4f84..bef62962 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Deploy GitHub runner image builder with GitHub runners. You'll need a working [OpenStack installation](https://microstack.run/docs/single-node) with -flavors with a minimum of 2 CPU cores, 8GB RAM and 10GB disk. +flavors with a minimum of two CPU cores, 8GB RAM and 10GB disk. ### Set up diff --git a/docs/changelog.md b/docs/changelog.md index 8d00d65c..f1159b40 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,7 +2,7 @@ ## [#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. +* 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. @@ -29,7 +29,7 @@ ### Bug Fixes -* The proxy configuration was not set for the snap install of aproxy during image building, causing the image building to fail if snapstore need to be accessed through a proxy. This is fixed. +* The proxy configuration was not set for the snap install of a proxy during image building, causing the image building to fail if the Snap Store needs to be accessed through a proxy. This is fixed. ## [#144 feat(docs): Evolve and standardize the documentation workflow](https://github.com/canonical/github-runner-image-builder-operator/pull/144) (2025-08-22) diff --git a/docs/how-to/configure-build-interval.md b/docs/how-to/configure-build-interval.md index 71c23869..deae320d 100644 --- a/docs/how-to/configure-build-interval.md +++ b/docs/how-to/configure-build-interval.md @@ -21,4 +21,4 @@ juju deploy github-runner-image-builder \ --config openstack-user-name=$OPENSTACK_USERNAME ``` -The example above would build images every three hours, from the latest version of dependent sources (cloud-images, apt, snap, etc). \ No newline at end of file +The example above would build images every three hours, from the latest version of dependent sources (cloud-images, apt, snap, and so on). \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 5b3c0b7f..a0645ad4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -21,7 +21,7 @@ SRE teams through Juju's clean interface. ## Contributing to this documentation -Documentation is an important part of this project, and we take the same open-source approach to the documentation as the code. As such, we welcome community contributions, suggestions and constructive feedback on our documentation. Our documentation is hosted on the [Charmhub forum](https://discourse.charmhub.io/t/github-runner-image-builder-documentation-overview) to enable easy collaboration. Please use the "Help us improve this documentation" links on each documentation page to either directly change something you see that's wrong, ask a question, or make a suggestion about a potential change via the comments section. +Documentation is an important part of this project, and we take the same open-source approach to the documentation as the code. As such, we welcome community contributions, suggestions and constructive feedback on our documentation. Our documentation is hosted on the [Charmhub forum](https://discourse.charmhub.io/t/github-runner-image-builder-documentation-overview) to enable easy collaboration. Please use the "Help us improve this documentation" links on each documentation page to either directly change something you see that's wrong, ask a question, or make a suggestion about a potential change through the comments section. If there's a particular area of documentation that you'd like to see that's missing, please [file a bug](https://github.com/canonical/github-runner-image-builder-operator/issues). diff --git a/docs/reference/charm-architecture.md b/docs/reference/charm-architecture.md index 8c9c0e2f..fc3b57dd 100644 --- a/docs/reference/charm-architecture.md +++ b/docs/reference/charm-architecture.md @@ -41,17 +41,17 @@ The image-builder uses an OpenStack cloud to build images. Through integration with another charm, the charm obtains the credentials to upload the images to a specified OpenStack project, which can then be reused by the other charm to spawn VM instances with the necessary software preinstalled. -The image-builder uses the [OpenStack SDK](https://docs.openstack.org/openstacksdk/latest/) to spawn a VM instance in a cloud specified +The image-builder uses the [OpenStack SDK](https://docs.openstack.org/openstacksdk/latest/) to spawn a VM instance in a cloud specified by a config option. Using an external OpenStack VM instead of the charm's machine allows for more features (using chroot has some limitations, e.g. for building snaps) and parallel image building. [cloud-init](https://cloud-init.io/) is used to install the necessary dependencies for spawning self-hosted runners -([github actions runner binary](https://github.com/actions/runner)) and tools for automatic proxy support ([aproxy](https://github.com/canonical/aproxy)). +([GitHub Actions runner binary](https://github.com/actions/runner)) and tools for automatic proxy support ([proxy tool](https://github.com/canonical/aproxy)). There is also a custom script configuration combined with a secret that is run in the cloud-init script to allow further customization of the images. The image-builder repeatedly checks to see if the cloud-init script has finished successfully, then snapshots the VM, uploads the image to a specified OpenStack project -and deletes the VM. This specified OpenStack project is determined via the `image:github_runner_image_v0` integration with another charm (e.g. [GitHub Runner Charm](https://charmhub.io/github-runner)). +and deletes the VM. This specified OpenStack project is determined through the `image:github_runner_image_v0` integration with another charm (e.g. [GitHub Runner Charm](https://charmhub.io/github-runner)). The other charm can then use the image to create a VM instance with the required software preinstalled. It receives -the image ID from the Image Builder charm via the integration mentioned above. +the image ID from the Image Builder charm through the integration mentioned above. Depending on the configuration, the charm will trigger multiple image builds in parallel to speed up the process. This leads to multiple OpenStack VMs in the OpenStack cloud (and requires corresponding OpenStack quotas) and multiple @@ -66,7 +66,7 @@ and uploaded to OpenStack. The image-builder application is initialized by the charm before it can be used. Initialization includes -- Downloading and validating the base images (e.g. Ubuntu 22.04 or 24.04) +- Downloading and validating the base images (e.g. Ubuntu 22.04 LTS or Ubuntu 24.04 LTS) - Uploading the base images to OpenStack - Creating key pairs and security groups in OpenStack @@ -115,7 +115,7 @@ Once the build is complete, the image-builder will upload the image taking into ## Charm code overview -The `src/charm.py` is the default entry point for a charm and has the GithubRunnerImageBuilderCharm Python class which inherits from CharmBase. CharmBase is the base class +The `src/charm.py` is the default entry point for a charm and has the GitHubRunnerImageBuilderCharm Python class which inherits from CharmBase. CharmBase is the base class from which all charms are formed, defined by [Ops](https://juju.is/docs/sdk/ops) (Python framework for developing charms). > See more in the Juju docs: [Charm](https://documentation.ubuntu.com/juju/3.6/reference/charm/) @@ -133,7 +133,7 @@ juju config github-runner-image-builder build-interval=3 ```python self.framework.observe(self.on.config_changed, self._on_config_changed) ``` -4. The method `_on_config_changed`, for its turn, will take the necessary actions such as updating the cron job's interval to 3 hours. +4. The method `_on_config_changed`, for its turn, will take the necessary actions such as updating the cron job's interval to three hours. The code is structured according to the best practices described in [Managing charm complexity](https://discourse.charmhub.io/t/specification-isd014-managing-charm-complexity/11619). diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index 0b41073b..c41fe923 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -46,7 +46,7 @@ juju deploy github-runner-image-builder \ --config openstack-user-name=$OPENSTACK_USERNAME ``` -- Verify that the image is being built via Juju logs: +- Verify that the image is being built using Juju logs: ``` juju debug-log --include=github-runner-image-builder/0 ```