Skip to content

Added generated OpenAPI client to GARM#232

Merged
yhaliaw merged 19 commits into
mainfrom
feat/garm-api-client
Jun 17, 2026
Merged

Added generated OpenAPI client to GARM#232
yhaliaw merged 19 commits into
mainfrom
feat/garm-api-client

Conversation

@yhaliaw

@yhaliaw yhaliaw commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

This PR targets the GARM charm.

  • Add a script to generate the GARM HTTP API client with OpenAPI Generator. The generator image is pinned to a stable release tag (v7.23.0) in sync with .openapi-generator/VERSION.
  • The generated code is checked into this repo.
  • Added a GARM API client class that uses the generated code. Currently, it supports the /first_run API, which is used to register a user on first run of GARM.
  • Modify charm.py to ensure the first run API is called once. GARM is served on a single fixed port (8080); _maybe_first_run connects via loopback using GARM_PORT and correctly wraps IPv6 addresses in [...].
  • First-run initialisation is gated to the leader unit to prevent race conditions on multi-unit deployments.
  • Merged with main branch changes: _workload_config pins the workload port to GARM_PORT and disables the framework's default metrics scrape job (metrics are declared in paas-config.yaml).

Why we need it

Standardize the API calling process in the GARM charm.
Register the user of GARM in the GARM charm.

Checklist

  • Changes comply with the project's coding standards and guidelines (see CONTRIBUTING.md and STYLE.md)
  • CONTRIBUTING.md has been updated upon changes to the contribution/development process (e.g. changes to the way tests are run)
  • Technical author has been assigned to review the PR in case of documentation changes (usually *.md files)
  • I updated docs/changelog.md with user-relevant changes
  • I used AI to assist with preparing this PR
  • I added or updated tests as needed (unit and integration)
  • If integration test modules are used: I updated the workflow configuration
    (e.g., in .github/workflows/integration_tests.yaml, ensure the modules list is correct)
  • If this PR involves a Grafana dashboard: I added a screenshot of the dashboard
  • If this PR involves Terraform: terraform fmt passes and tflint reports no errors
  • If this PR involves Rockcraft: I updated the version

@yhaliaw yhaliaw marked this pull request as ready for review June 12, 2026 06:21
@cbartz cbartz requested a review from Copilot June 12, 2026 06:23

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

Comment thread charms/garm/scripts/generate_client.sh
Comment thread charms/garm/src/charm.py
Comment thread charms/garm/tests/unit/test_garm_api.py
Comment thread charms/garm/src/garm_api.py Outdated

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 13 out of 13 changed files in this pull request and generated 8 comments.

Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py
Comment thread charms/garm/src/charm.py
Comment thread charms/garm/scripts/generate_client.sh Outdated
Comment thread charms/garm/scripts/generate_client.sh Outdated
Comment thread charms/garm/requirements.txt Outdated
Comment thread charms/garm/pyproject.toml
Comment thread charms/garm/src/charm.py
@yhaliaw yhaliaw marked this pull request as draft June 15, 2026 05:33
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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 18 out of 18 changed files in this pull request and generated 5 comments.

Comment thread charms/garm/src/garm_api.py
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/tox.toml
Comment thread charms/garm/scripts/generate_client.sh
Comment thread images/bare/index.json Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@yhaliaw

yhaliaw commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in the latest commit. Three files had conflicts:

  • charms/garm/src/charm.py: Kept _workload_config from main (replacing _listen_port), updated _maybe_first_run to use GARM_PORT directly, and dropped the listen_address argument from the render_garm_toml call.
  • charms/tests/integration/test_garm.py: Kept GARM_ADMIN_CREDENTIALS_LABEL, updated GARM_API_PORT to 8080, preserved the admin-credentials assertions from this branch, and added the new test_garm_metrics_endpoint_no_auth test from main.
  • docs/changelog.md: Kept both entries with the 2026-06-15 entry first.

All 25 unit tests pass.

@yhaliaw yhaliaw marked this pull request as ready for review June 16, 2026 08:45
@yhaliaw yhaliaw requested a review from cbartz June 16, 2026 08:45
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py Outdated
Comment thread charms/garm/src/charm.py

@yanksyoon yanksyoon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor comments, LGTM.

Comment thread charms/garm/src/charm.py
Comment thread charms/garm/tests/unit/test_charm.py
@yhaliaw yhaliaw merged commit 0df864f into main Jun 17, 2026
69 of 79 checks passed
@yhaliaw yhaliaw deleted the feat/garm-api-client branch June 17, 2026 05:26
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.

5 participants