Open carlcsaposs-canonical opened 4 months ago
for comparison, before this change, the order would've been self._database_provides.delete_all_databags()
, then disable the workload
(instead of disable the workload, then self._database_provides.delete_all_databags()
)
Tony is unlikely to get to this this cycle, but we still want to fix this.
ops 2.10 introduced a breaking change that excludes breaking relations from Model.relations: https://github.com/canonical/operator/pull/1091
In order to access relation data for the breaking relation, we need to use
event.relation
—but this doesn't work in deferred ops events, custom ops events, or collect status ops events.With ops, it is no longer possible to access the breaking relation data in those ops events during the relation-broken Juju event
Example of impact: mysql-router-k8s is currently written with no deferred events, no custom events during the relation-broken event, and no ops collect status events (because of limitations with status prioritization)—so it is not currently affected However, if mysql-router-k8s were to use deferred events in the future, or one of the charm libs it depends on were to use a deferred event or a custom event during relation-broken, it would be affected as following:
if self._database_requires.is_relation_breaking(event):
evaluates toif False
and is skippedevaluates to
elif False
because relation data for databaserequires is missing (trace: [workload is not AuthenticatedWorkload](https://github.com/canonical/mysql-router-k8s-operator/blob/156da2da8c68c65ae262b2721cc01fb1b974104f/src/abstract_charm.py#L164) because relation is missing)workload_.reconcile()
disables MySQL Router because workload_ is not AuthenticatedWorkload because relation is missingCurrent state: MySQL Router is disabled, but relation data in database_provides relations is still populated—mysql-router-k8s charm is giving consuming charms an endpoint and telling them that it should be accessible when Router is disabled & unreachable—this causes a poor UX (consuming applications will probably display incorrect status message) and could cause issues with exponential backoffs (i.e. a delay in service restoration) when MySQL Router is re-enabled
potentially for an extended period of time—which causes the aforementioned issues with UX & exponential backoff