Skip to content

ci: reclaim OpenStack orphans at integration test start#808

Draft
cbartz wants to merge 9 commits into
mainfrom
ci/openstack-ci-resource-cleanup
Draft

ci: reclaim OpenStack orphans at integration test start#808
cbartz wants to merge 9 commits into
mainfrom
ci/openstack-ci-resource-cleanup

Conversation

@cbartz

@cbartz cbartz commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

At OpenStack integration-test connect, delete CI-named leftover resources older than 6h (servers, keypairs, images, test SGs). Covers charm and github-runner-manager suites. Force-cancelled prior runs are reclaimed the next time a suite starts.

Why we need it

Force-cancel / fixture failure leaves VMs and keypairs in the private-endpoint tenant. Start-of-run orphan cleanup reclaims them without a separate scheduled workflow.

Checklist

  • I followed the contributing guide
  • I added or updated the documentation (if applicable)
  • 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 this is a Grafana dashboard: I added a screenshot of the dashboard
  • If this is Terraform: terraform fmt passes and tflint reports no errors
  • If the github-runner-manager application has been changed: The application version number is updated in github-runner-manager/pyproject.toml.

Add a script that deletes dangling servers, keypairs, images and
test security groups left by integration tests, plus a 6-hourly
workflow on the private-endpoint runner.
cbartz added 2 commits July 16, 2026 13:48
Drop the scheduled cleanup workflow. Force-cancelled runs leave
resources behind; the next integration suite now deletes CI-named
OpenStack leftovers older than 6h before creating new ones.
Public cleanup entry point first; private helpers below. Module-level
imports in conftest instead of inline.
@cbartz
cbartz requested a review from Copilot July 16, 2026 13:56
@cbartz cbartz changed the title ci: schedule OpenStack CI resource cleanup ci: reclaim OpenStack orphans at integration test start Jul 16, 2026

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 adds a start-of-integration-run “orphan reaper” for OpenStack resources created by CI, so resources left behind by force-cancelled or failed runs are reclaimed automatically the next time the integration suites connect to the tenant.

Changes:

  • Added OpenStack orphan cleanup helpers that delete CI-named resources older than 6 hours (servers, images, keypairs, and test security groups).
  • Hooked orphan cleanup into both the charm integration suite and the github-runner-manager integration suite at OpenStack connection time.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/integration/helpers/orphan_cleanup.py New charm-suite OpenStack orphan cleanup helper, including server/image/keypair/SG deletion logic.
tests/integration/conftest.py Invokes orphan cleanup at the start of the charm integration suite OpenStack connection fixture.
github-runner-manager/tests/integration/orphan_cleanup.py New manager-suite OpenStack orphan cleanup helper (servers/keypairs/SGs).
github-runner-manager/tests/integration/conftest.py Invokes orphan cleanup at the start of the manager integration suite OpenStack connection fixture.

Comment thread tests/integration/helpers/orphan_cleanup.py
Comment thread tests/integration/helpers/orphan_cleanup.py
Comment thread github-runner-manager/tests/integration/orphan_cleanup.py
Keypairs often lack created_at; treating unknown age as stale risked
deleting in-progress CI resources. Skip those instead.

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

Comment thread tests/integration/conftest.py
Comment thread tests/integration/helpers/orphan_cleanup.py Outdated
Comment thread github-runner-manager/tests/integration/orphan_cleanup.py Outdated
Comment thread github-runner-manager/tests/integration/orphan_cleanup.py
Comment thread github-runner-manager/tests/integration/orphan_cleanup.py
Wait for server delete before SGs, keep OpenStack teardown inside the
connection context, best-effort start-up reaping, and tighten
test-id regexes to the 8-char CI ids we generate.

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/integration/conftest.py Outdated
Align OpenStack teardown/orphan helpers with existing integration
suite call conventions.

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

Comment thread tests/integration/helpers/orphan_cleanup.py
Comment thread github-runner-manager/tests/integration/orphan_cleanup.py Outdated
Comment thread tests/integration/conftest.py Outdated
Keep suite call style consistent; openstacksdk accepts the name
positionally as used elsewhere in this repository.

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

Comment thread tests/integration/helpers/orphan_cleanup.py
Comment thread tests/integration/conftest.py Outdated
Drop wait= on image delete (not supported), materialize list_servers,
and log orphan cleanup failures with exc_info.

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tests/integration/conftest.py Outdated
--use-existing-app-suffix is for local runs that keep long-lived
resources; do not reap them at suite start.
@cbartz
cbartz requested a review from Copilot July 16, 2026 14:58

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants