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
9 stars 9 forks source link

Lib tries to access app databag from non-leader unit #111

Open carlcsaposs-canonical opened 9 months ago

carlcsaposs-canonical commented 9 months ago

unit-mysql-router-k8s-1: 21:13:42 ERROR unit.mysql-router-k8s/1.juju-log backend-database:6: This operation (update_relation_data()) can only be performed by the leader unit

Originally posted by @juditnovak in https://github.com/canonical/mysql-router-k8s-operator/issues/152#issuecomment-1787984013

github-actions[bot] commented 9 months ago

https://warthogs.atlassian.net/browse/DPE-2881

carlcsaposs-canonical commented 9 months ago

https://github.com/canonical/data-platform-libs/blob/e4bb320b70c60d2cc9b6e6890826f97d151bada3/lib/charms/data_platform_libs/v0/data_interfaces.py#L1917-L1924

Here the lib writes to the app databag without checking if the unit is leader, causing an error log to be written

(The super method checks for leadership, but only returns if not leader)