app relation data cannot be read in non leader units
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Opinion
|
Medium
|
Unassigned |
Bug Description
Hello,
I found a bug similar to this one: https:/
Non-leaders shouldn't have rights to write into the application data, but I'm getting permission denied error reading the application relation data from a non-leader unit.
Logs:
Traceback (most recent call last):
File "/var/lib/
result = run(args, **kwargs)
File "/usr/lib/
raise CalledProcessEr
subprocess.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./src/charm.py", line 81, in <module>
main(
File "/var/lib/
_emit_
File "/var/lib/
event_
File "/var/lib/
framework.
File "/var/lib/
self.
File "/var/lib/
custom_
File "./src/charm.py", line 44, in on_relation_joined
logger.
File "/var/lib/
return repr(self._data)
File "/var/lib/
return repr(self._data)
File "/var/lib/
data = self._lazy_data = self._load()
File "/var/lib/
return self._backend.
File "/var/lib/
return self._run(*args, return_output=True, use_json=True)
File "/var/lib/
raise ModelError(
ops.model.
The provides/8 unit, as you can see here, is not the leader:
Model Controller Cloud/Region Version SLA Timestamp
test microk8s-localhost microk8s/localhost 2.8.7 unsupported 15:57:46+01:00
App Version Status Scale Charm Store Rev OS Address N
otes
provides ubuntu:latest active 2 provides local 7 kubernetes 10.152.183.207
Unit Workload Agent Address Ports Message
provides/7* active idle 10.1.245.85 80/TCP
provides/8 error idle 10.1.245.87 80/TCP hook failed: "dummy-
IIRC, this is by design.
Only leaders can read/write application relation data.
To propagate that data to other application units, use a peer relation and have the leader update the data in that peer relation as needed.