canonical / data-platform-libs

A collection of charm libraries curated by the Data Platform Team
https://charmhub.io/data-platform-libs
Apache License 2.0
10 stars 9 forks source link

[DPE-2269] Added k8s upgrade handler #77

Closed marceloneppel closed 1 year ago

marceloneppel commented 1 year ago

Issue

UpgradeGrantedEvent is emitted when the charm is allowed to upgrade the workload, but on K8s it's already upgraded when the charm receives UpgradCharmEvent and the other events that are fired later. For K8s, we need a different event, that tells that the upgrade was finished in the current unit and Juju can proceed to the next unit.

Solution

Created UpgradeFinishedEvent to be used to tell Juju to upgrade the next unit (by, for example, changing the partition field from the StatefulSet rolling update strategy). Logic for that was kept in the charms themselves for now to let them do some additional logic if needed.

Conditionals were added to trigger UpgradeRelationChangedEvent in the current unit on K8s, which avoid losing the event when we have only part of the units in the new charm revision.

Added PyYAML to charm-binary-python-packages due to https://github.com/yaml/pyyaml/issues/601.