Skip to content

refactor(garm): move workload config to entrypoint - #304

Merged
yanksyoon merged 26 commits into
mainfrom
chore/refactor-reconcile-isd-6013
Aug 12, 2026
Merged

refactor(garm): move workload config to entrypoint#304
yanksyoon merged 26 commits into
mainfrom
chore/refactor-reconcile-isd-6013

Conversation

@yanksyoon

@yanksyoon yanksyoon commented Aug 10, 2026

Copy link
Copy Markdown
Member
image image

Summary

  • Move GARM config and provider-file rendering into the container entrypoint.
  • Pass workload configuration through environment variables and use the paas-charm application environment handling.
  • Preserve normalized HTTP, HTTPS, and no-proxy environment propagation.
  • Add entrypoint unit coverage and update the GARM rock layout.

Test plan

  • tox -c tox.toml -e static — passed.
  • tox -c tox.toml -e fmt — passed.
  • ruff check and ruff format --check on changed production files — passed.
  • tests/unit/test_garm_entrypoint.py — 7 passed.

Note: the full unit environment is currently blocked during collection because tests/unit/test_garm_toml.py still imports config-rendering helpers removed by this refactor (_build_provider_list, _proxy_environment, and render_garm_toml).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the garm charm/workload boundary so that GARM’s file-based configuration (config.toml + provider files) is rendered inside the container entrypoint from environment variables, aligning the workload more closely with the paas-charm 12-factor model.

Changes:

  • Added a Python-based GARM entrypoint (garm_entrypoint.py) plus dedicated unit tests for config rendering and execution behavior.
  • Updated the garm charm to pass workload configuration via environment variables and to point the Pebble service at the entrypoint via a custom App wrapper.
  • Updated the GARM rockcraft definition to include Python dependencies and install the entrypoint script, and adjusted related unit tests and ignore rules.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
garm-rockcraft.yaml Adds Python dependencies + installs the entrypoint script; modifies the base Pebble layer command/startup behavior.
charms/garm/uv.lock Updates the lockfile’s declared requires-python constraint.
charms/garm/tests/unit/test_garm_entrypoint.py New unit tests covering entrypoint config rendering, path safety, and exec behavior.
charms/garm/tests/unit/test_charm.py Updates Scenario-based tests to validate env-driven configuration and the new service naming/command behavior.
charms/garm/src/garm_entrypoint.py New entrypoint implementation: reads env, renders TOML/YAML files, and execs the GARM binary.
charms/garm/src/charm.py Refactors charm-side config handling to env-only, introduces GarmApp, and updates restart/config logic.
.gitignore Ignores virtualenv and additional charm/terraform generated directories.
Suppressed comments (2)

charms/garm/src/charm.py:193

  • GarmApp.restart() accepts rerun_migrations but discards it by calling super().restart() without passing the flag. This can prevent the charm’s rerun_migrations path from working as intended.
class GarmCharm(paas_charm.go.Charm):
    """GARM charm — manages the GARM service via Pebble."""

    def __init__(self, *args: typing.Any) -> None:
        """Initialize the charm.

charms/garm/src/charm.py:334

  • The _compute_state docstring still claims it returns provider configuration files to push, but the refactor now passes provider config via GARM_PROVIDERS_JSON and the entrypoint owns file rendering. This makes the docstring misleading.

        Returns a ``ComputeState`` containing the environment variables the
        GARM entrypoint needs and the provider configuration files to push.
        When paas-charm gains native ``_compute_state`` support, this data
        gathering can be returned directly and the ``GarmApp`` wrapper

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py
Comment thread garm-rockcraft.yaml Outdated
Comment thread charms/garm/tests/unit/test_charm.py Outdated
Comment thread charms/garm/tests/unit/test_charm.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

charms/garm/src/garm_entrypoint.py:127

  • GARM_PROVIDERS_JSON is decoded with json.loads(...) without handling JSONDecodeError or validating the decoded type. If the env var is set but malformed (or not a JSON list), the entrypoint will crash with a traceback or behave unexpectedly.
    providers_json = env.get("GARM_PROVIDERS_JSON", "")
    providers = json.loads(providers_json) if providers_json else []

charms/garm/src/garm_entrypoint.py:83

  • POSTGRESQL_DB_PORT is parsed with int(...) without validation; a malformed value will raise ValueError and crash the entrypoint with a traceback. It’s better to raise a clear ValueError that main() can log and exit on.

This issue also appears on line 126 of the same file.

    db_port = int(env.get("POSTGRESQL_DB_PORT", DEFAULT_DB_PORT))
    db_name = env.get("POSTGRESQL_DB_NAME", DEFAULT_DB_NAME)

Comment thread charms/garm/src/garm_entrypoint.py Outdated
@yanksyoon
yanksyoon marked this pull request as ready for review August 11, 2026 05:28

@yhaliaw yhaliaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major changes needed


🤝 Human review with AI assistance.

Comment thread charms/garm/src/charm.py
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/tests/unit/test_charm.py Outdated
Comment thread charms/garm/tests/unit/test_charm.py Outdated
Comment thread charms/tests/integration/test_garm.py Outdated
@yanksyoon
yanksyoon requested a review from yhaliaw August 12, 2026 03:46
@yanksyoon
yanksyoon merged commit 1f949c2 into main Aug 12, 2026
61 checks passed
@yanksyoon
yanksyoon deleted the chore/refactor-reconcile-isd-6013 branch August 12, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants