Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c88df24
Support proxy values
swetha1654 Jan 20, 2026
5ca542c
static errors
swetha1654 Jan 20, 2026
209479e
fix static and lint issues
swetha1654 Jan 20, 2026
903ce2f
fix static and lint inside app
swetha1654 Jan 20, 2026
72d8d3f
abort on fail
swetha1654 Jan 20, 2026
26b2965
add changelog
swetha1654 Jan 20, 2026
3f37f58
vale error
swetha1654 Jan 20, 2026
4860270
delete chain and run integ tests
swetha1654 Jan 27, 2026
f74433b
chore(deps): update dependency openstacksdk to v4.9.0 (#184)
renovate[bot] Jan 22, 2026
83fffe4
chore: update charm libraries (#177)
github-actions[bot] Jan 22, 2026
9e8f934
Merge branch 'main' into ISD-3652-aproxy2
swetha1654 Jan 27, 2026
e49a597
Update src/builder.py
swetha1654 Jan 27, 2026
d901d07
remove pyproject update
swetha1654 Jan 27, 2026
ad07dc9
address code review
swetha1654 Feb 5, 2026
7cb4485
remove tesT
swetha1654 Feb 5, 2026
1d7a529
test
swetha1654 Feb 6, 2026
7ef5451
update prerouting chain
swetha1654 Feb 10, 2026
417b9ef
fix script
swetha1654 Feb 10, 2026
08d10b4
fix script
swetha1654 Feb 10, 2026
1e68b2a
update builder initializer
swetha1654 Feb 10, 2026
efbadff
remove all code
swetha1654 Feb 10, 2026
a89fbdb
remove code
swetha1654 Feb 10, 2026
47c6b97
remove code
swetha1654 Feb 10, 2026
b804d34
setup proxy env for all hooks
swetha1654 Feb 10, 2026
b57f7ae
fix lint issues
swetha1654 Feb 10, 2026
2f7a6f2
Merge branch 'main' into ISD-3652-aproxy2
swetha1654 Feb 10, 2026
40db4e1
remove lint
swetha1654 Feb 10, 2026
60cd863
add more logs
swetha1654 Feb 10, 2026
130b7f7
remove randomly added code
swetha1654 Feb 10, 2026
cc9f619
lint issues
swetha1654 Feb 10, 2026
d3befa1
disable noproxy and check
swetha1654 Feb 11, 2026
608545b
experiment with no proxy
swetha1654 Feb 11, 2026
51761f9
debug
swetha1654 Feb 12, 2026
ca7e35e
debug
swetha1654 Feb 12, 2026
210216d
debug
swetha1654 Feb 12, 2026
2cb34b4
remove integration test
swetha1654 Feb 17, 2026
5c7ec25
chore(deps): update all non-major dependencies (#190)
renovate[bot] Feb 13, 2026
960d6b3
feat: otel-collector snap (#195)
swetha1654 Feb 17, 2026
cc5d29b
Merge branch 'main' into ISD-3652-aproxy2
swetha1654 Feb 17, 2026
51782dc
address review comments
swetha1654 Feb 17, 2026
cac7063
fix unit test
swetha1654 Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

<!-- vale Canonical.007-Headings-sentence-case = NO -->

## [#185 Remove aproxy installation and add proxy support in workload](https://github.com/canonical/github-runner-image-builder-operator/pull/185) (2026-01-20)
* Remove `aproxy` snap installation in the charm and inject proxy values from the model config into the workload process.

## [#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.

Expand Down
4 changes: 3 additions & 1 deletion src/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
OPENSTACK_CLOUDS_YAML_PATH = UBUNTU_HOME / "clouds.yaml"

# Bandit thinks this is a hardcoded secret
IMAGE_BUILDER_SECRET_PREFIX = "IMAGE_BUILDER_SECRET_" # nosec: B105
IMAGE_BUILDER_SECRET_PREFIX = "IMAGE_BUILDER_SECRET_" # nosec: hardcoded_password_string


@dataclasses.dataclass
Expand Down Expand Up @@ -188,6 +188,7 @@ def _build_init_command(
"""
cmd = [
"/usr/bin/sudo",
"--preserve-env=http_proxy,https_proxy,no_proxy,HTTP_PROXY,HTTPS_PROXY,NO_PROXY",
str(GITHUB_RUNNER_IMAGE_BUILDER_PATH),
"--os-cloud",
cloud_name,
Expand Down Expand Up @@ -528,6 +529,7 @@ def _run(config: RunConfig) -> list[CloudImage]:
env={
"HOME": str(UBUNTU_HOME),
**_transform_secrets(secrets=config.image.script_config.script_secrets),
**{k: v for (k, v) in os.environ.items() if "proxy" in k.lower()},
},
)
# The return value of the CLI is "Image build success:\n<comma-separated-image-ids>"
Expand Down
26 changes: 22 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import json
import logging
import os

# We ignore low severity security warning for importing subprocess module
import subprocess # nosec B404
Expand All @@ -22,7 +23,6 @@
import builder
import charm_utils
import image
import proxy
import state

LOG_FILE_DIR = Path("/var/log/github-runner-image-builder")
Expand Down Expand Up @@ -102,10 +102,10 @@ def _on_upgrade_charm(self, _: ops.UpgradeCharmEvent) -> None:
def _on_config_changed(self, _: ops.ConfigChangedEvent) -> None:
"""Handle charm configuration change events."""
builder_config_state = state.BuilderConfig.from_charm(charm=self)
self._setup_proxy_environment(builder_config_state.proxy)
if not self._is_any_image_relation_ready(cloud_config=builder_config_state.cloud_config):
return
# The following lines should be covered by integration tests.
proxy.configure_aproxy(proxy=state.ProxyConfig.from_env()) # pragma: no cover
builder.install_clouds_yaml( # pragma: no cover
cloud_config=builder_config_state.cloud_config.openstack_clouds_config
)
Expand All @@ -119,6 +119,7 @@ def _on_config_changed(self, _: ops.ConfigChangedEvent) -> None:
def _on_image_relation_changed(self, evt: ops.RelationChangedEvent) -> None:
"""Handle charm image relation changed event."""
builder_config_state = state.BuilderConfig.from_charm(charm=self)
self._setup_proxy_environment(builder_config_state.proxy)
if not evt.unit:
logger.info("No unit in image relation changed event. Skipping image building.")
return
Expand All @@ -132,7 +133,6 @@ def _on_image_relation_changed(self, evt: ops.RelationChangedEvent) -> None:
evt.unit.name,
)
return
proxy.configure_aproxy(proxy=state.ProxyConfig.from_env())
builder.install_clouds_yaml(
cloud_config=builder_config_state.cloud_config.openstack_clouds_config
)
Expand All @@ -158,6 +158,7 @@ def _on_image_relation_changed(self, evt: ops.RelationChangedEvent) -> None:
def _on_run(self, _: RunEvent) -> None:
"""Handle the run event."""
builder_config_state = state.BuilderConfig.from_charm(charm=self)
self._setup_proxy_environment(builder_config_state.proxy)
if not self._is_any_image_relation_ready(cloud_config=builder_config_state.cloud_config):
return
# The following line should be covered by the integration test.
Expand All @@ -171,16 +172,33 @@ def _on_run_action(self, event: ops.ActionEvent) -> None:
event: The run action event.
"""
builder_config_state = state.BuilderConfig.from_charm(charm=self)
self._setup_proxy_environment(builder_config_state.proxy)
if not self._is_any_image_relation_ready(cloud_config=builder_config_state.cloud_config):
event.fail("Image relation not yet ready.")
return
# The following line should be covered by the integration test.
self._run() # pragma: nocover

def _setup_proxy_environment(self, proxy_config: state.ProxyConfig | None) -> None:
"""Set up proxy environment variables.

Args:
proxy_config: The proxy configuration to apply to environment variables.
"""
if proxy_config:
os.environ["http_proxy"] = proxy_config.http
os.environ["https_proxy"] = proxy_config.https
os.environ["no_proxy"] = proxy_config.no_proxy
os.environ["HTTP_PROXY"] = proxy_config.http
os.environ["HTTPS_PROXY"] = proxy_config.https
os.environ["NO_PROXY"] = proxy_config.no_proxy

def _setup_builder(self) -> None:
"""Set up the builder application."""
proxy.setup(proxy=state.ProxyConfig.from_env())
builder_config_state = state.BuilderConfig.from_charm(charm=self)

self._setup_proxy_environment(builder_config_state.proxy)

builder.initialize(
app_init_config=builder.ApplicationInitializationConfig(
cloud_config=builder_config_state.cloud_config,
Expand Down
4 changes: 0 additions & 4 deletions src/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class BuilderRunError(BuilderBaseError):
"""Represents an error while running the image builder."""


class ProxyInstallError(BuilderBaseError):
"""Represents an error while installing proxy."""


class GetLatestImageError(BuilderBaseError):
"""Represents an error while fetching the latest image."""

Expand Down
83 changes: 0 additions & 83 deletions src/proxy.py

This file was deleted.

6 changes: 3 additions & 3 deletions src/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
EXTERNAL_BUILD_NETWORK_CONFIG_NAME = "build-network"
OPENSTACK_AUTH_URL_CONFIG_NAME = "openstack-auth-url"
# Bandit thinks this is a hardcoded password
OPENSTACK_PASSWORD_CONFIG_NAME = "openstack-password" # nosec: B105
OPENSTACK_PASSWORD_CONFIG_NAME = "openstack-password" # nosec: hardcoded_password_string
OPENSTACK_PROJECT_DOMAIN_CONFIG_NAME = "openstack-project-domain-name"
OPENSTACK_PROJECT_CONFIG_NAME = "openstack-project-name"
OPENSTACK_USER_DOMAIN_CONFIG_NAME = "openstack-user-domain-name"
Expand All @@ -39,8 +39,8 @@
RUNNER_VERSION_CONFIG_NAME = "runner-version"
SCRIPT_URL_CONFIG_NAME = "script-url"
# Bandit thinks this is a hardcoded password
SCRIPT_SECRET_ID_CONFIG_NAME = "script-secret-id" # nosec: B105
SCRIPT_SECRET_CONFIG_NAME = "script-secret" # nosec: B105
SCRIPT_SECRET_ID_CONFIG_NAME = "script-secret-id" # nosec: hardcoded_password_string
SCRIPT_SECRET_CONFIG_NAME = "script-secret" # nosec: hardcoded_password_string

IMAGE_RELATION = "image"

Expand Down
5 changes: 5 additions & 0 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def test_image_relation(app: Application, test_charm: Application):


@pytest.mark.asyncio
@pytest.mark.abort_on_fail
async def test_cos_agent_relation(app: Application):
"""
arrange: An active charm.
Expand All @@ -55,6 +56,7 @@ async def test_cos_agent_relation(app: Application):


@pytest.mark.asyncio
@pytest.mark.abort_on_fail
async def test_build_image(
openstack_connection: Connection,
dispatch_time: datetime,
Expand All @@ -70,6 +72,7 @@ async def test_build_image(

# Ignore the "too many arguments" warning, as this is not significant for a test function where
# the arguments are fixtures and the function is not expected to be called directly.
@pytest.mark.abort_on_fail
async def test_charm_another_app_does_not_rebuild_image( # pylint: disable=R0913,R0917
app: Application,
test_charm: Application,
Expand Down Expand Up @@ -128,6 +131,7 @@ async def test_charm_another_app_does_not_rebuild_image( # pylint: disable=R091


@pytest.mark.asyncio
@pytest.mark.abort_on_fail
async def test_periodic_rebuilt(
app: Application,
app_config: dict,
Expand Down Expand Up @@ -179,6 +183,7 @@ async def _change_cronjob_to_minutes(unit: Unit, current_hour_interval: int):


@pytest.mark.asyncio
@pytest.mark.abort_on_fail
async def test_log_rotated(app: Application):
"""
arrange: A deployed active charm and manually write something to the log file.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class CloudAuthFactory(factory.DictFactory):

auth_url = "http://testing-auth/keystone"
# We need to use known password for unit testing
password = "test-password" # nosec: B105:hardcoded_password_string
password = "test-password" # nosec: hardcoded_password_string
project_domain_name = "test-project-domain"
project_name = "test-project-name"
user_domain_name = "test-user-domain"
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def test__initialize_image_builder_error(
None,
[
"/usr/bin/sudo",
"--preserve-env=http_proxy,https_proxy,no_proxy,HTTP_PROXY,HTTPS_PROXY,NO_PROXY",
"/home/ubuntu/.local/bin/github-runner-image-builder",
"--os-cloud",
"test-cloud-name",
Expand All @@ -199,6 +200,7 @@ def test__initialize_image_builder_error(
"test-prefix",
[
"/usr/bin/sudo",
"--preserve-env=http_proxy,https_proxy,no_proxy,HTTP_PROXY,HTTPS_PROXY,NO_PROXY",
"/home/ubuntu/.local/bin/github-runner-image-builder",
"--os-cloud",
"test-cloud-name",
Expand Down
Loading
Loading