canonical / openfga-operator

Charmed OpenFGA
https://charmhub.io/openfga-k8s
Apache License 2.0
1 stars 5 forks source link

Fix scaled requirer charm #38

Closed kelkawi-a closed 5 months ago

kelkawi-a commented 5 months ago

This PR addresses a bug where if a requirer charm that is related to the OpenFGA charm is scaled to more than 1 unit, the following error shows in the logs:

unit-temporal-k8s-1: 14:29:17 ERROR unit.temporal-k8s/1.juju-log openfga:18: Uncaught exception while in charm code:
...
File "/var/lib/juju/agents/unit-temporal-k8s-1/charm/lib/charms/openfga_k8s/v1/openfga.py", line 240, in _on_relation_created
    OpenfgaRequirerAppData(store_name=self.store_name).dump(databag)
  File "/var/lib/juju/agents/unit-temporal-k8s-1/charm/lib/charms/openfga_k8s/v1/openfga.py", line 146, in dump
    databag[field.alias or key] = (
  File "/var/lib/juju/agents/unit-temporal-k8s-1/charm/venv/ops/model.py", line 1474, in __setitem__
    self._validate_write(key, value)
  File "/var/lib/juju/agents/unit-temporal-k8s-1/charm/venv/ops/model.py", line 1460, in _validate_write
    raise RelationDataAccessError(
ops.model.RelationDataAccessError: temporal-k8s/1 is not leader and cannot write application data.

Therefore, it checks for unit leadership before dumping data in the relation databag.

It also updates the README to reflect the new library version and instructions, as running a schema upgrade action is no longer required when the charm is initially deployed.