Make mysql-test-app container-aware for Juju 4.0 compatibility#53
Draft
Make mysql-test-app container-aware for Juju 4.0 compatibility#53
Conversation
- Add container and resource definitions to metadata.yaml - Update charm.py with Pebble awareness: - Add Layer import - Add container property and _is_container_ready() helper - Add pebble-ready observer and handler - Add centralized _update_status() method - Update event handlers to check container readiness first - All handlers now use _update_status() for consistent status management - Fix typo: "estabilshed" -> "established" Co-authored-by: astrojuanlu <316517+astrojuanlu@users.noreply.github.com>
Co-authored-by: astrojuanlu <316517+astrojuanlu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Make mysql-test-app container-aware for Juju 4.0 status display
Make mysql-test-app container-aware for Juju 4.0 compatibility
Jan 27, 2026
Contributor
|
This was me playing with Copilot, will have a proper look soon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The charm sets status based on database relation availability without checking container readiness, causing Juju 4.0 to display incorrect status (unknown/running when charm is active but container isn't ready).
Changes
Container Definition
Added Kubernetes container and OCI image resource to
metadata.yaml:Pebble Integration
_containerproperty and_is_container_ready()helpermysql_test_app_pebble_readyevent to configure Pebble layer_update_status()that enforces check order: container readiness → database availability_on_start,_on_update_status,_on_relation_changed,_on_relation_broken,_on_peer_relation_changed) to use centralized status methodStatus Progression
Container readiness now gates all status transitions, preventing premature ActiveStatus reports.
Original prompt
Make mysql-test-app container-aware to fix Juju 4.0 status display
Context
This charm is being used on Kubernetes but lacks proper container definitions and Pebble awareness. This causes status display issues in Juju 4.0 (see juju/juju#21641 and juju/juju#21671).
The charm currently sets
WaitingStatus()orActiveStatus()based solely on database relation availability, without checking if its own container is ready. This causes Juju to show inconsistent status displays:waiting(due to compatibility hacks)unknownorrunningwhen the charm thinks it's active but the container isn't readyRequired Changes
1. Add container and resource definitions to
metadata.yamlAdd the following to
metadata.yaml:2. Update
src/charm.pyto be Pebble-awareAdd the following changes to
src/charm.py:A. Update imports:
B. Add container property and helper methods after the existing properties:
C. Add pebble-ready observer in
__init__:D. Add the pebble-ready handler method:
E. Add centralized status update method:
F. Update
_on_startto check container readiness:G. Update
_on_update_statusto check container:H. Replace existing status setting calls:
Replace these existing method implementations: