canonical / observability-libs

A collection of charm libraries curated by the Observability team.
https://charmhub.io/observability-libs
Apache License 2.0
3 stars 8 forks source link

Transform `KubernetesComputeResourcesPatch` "Push" statuses into "Pull" statuses #107

Closed michaeldmitry closed 2 weeks ago

michaeldmitry commented 3 weeks ago

Issue

The way how v0 KubernetesComputeResourcesPatch currently behaves enforces charms using the library to implement a push status pattern to keep track of failures that might have happened during the patching. Even the existing function is_ready doesn't have enough info to determine whether the patch is not ready because it has failed or because its still in progress. That introduces an overhead of managing that "push" status and probably maintaining a StoredState in the charm.

Solution

Introduce a new API function get_status that gets the current status of the patch operation. get_status will return one of 3 possible states: 1- succeeded: a patch operation has completed successfully or the patch operation itself has not started yet. 2- failed: using dry-run mechanism, detect if the patch operation would've failed. 3- in_progress: rollout status-like logic to detect if the patch is still being applied and not fully ready.

Testing Instructions

A tandem PR for loki for using the new version of the library and test existing functionality as normal.

Upgrade Notes

Charms can continue using this new version of the library same way as before relying on is_ready as a push status. If charms wish to transform that as a pull status, they should start using get_status in collect-unit-status and depending on the state of the patch returned, set the desired state of the charm.

michaeldmitry commented 3 weeks ago

@PietroPasotti reverted the new files to ease the review and this PR is for testing the above changes in an existing codebase.