Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot index relation data with "None" #99

Closed
Abuelodelanada opened this issue Oct 26, 2022 · 1 comment
Closed

Cannot index relation data with "None" #99

Abuelodelanada opened this issue Oct 26, 2022 · 1 comment

Comments

@Abuelodelanada
Copy link
Contributor

Bug Description

When removing a relation (traefik_route interface) between traefik-k8s and grafana-k8s, and KeyError exception is raised:

KeyError: 'Cannot index relation data with "None". Are you trying to access remote app data during a relation-broken event? This is not allowed.'

To Reproduce

  1. Deploy cos: juju deploy cos-lite --trust
  2. Wait until all units are in active status
  3. Remove relations, for instance: jhack imatrix clear
  4. See in juju debug-log the errors

Environment

juju: 3.0.0 (and 2.9.35 as well)
microk8s: 1.25-strict

Relevant log output

unit-grafana-0: 00:56:30.249 INFO juju.worker.uniter.operation ran "grafana-source-relation-broken" hook (via hook dispatching script: dispatch)
unit-grafana-0: 00:56:32.056 ERROR unit.grafana/0.juju-log ingress:5: Uncaught exception while in charm code:
Traceback (most recent call last):
  File "./src/charm.py", line 1156, in <module>
    main(GrafanaCharm, use_juju_for_storage=True)
  File "/var/lib/juju/agents/unit-grafana-0/charm/venv/ops/main.py", line 426, in main
    charm = charm_class(framework)
  File "./src/charm.py", line 210, in __init__
    url=self.external_url,
  File "./src/charm.py", line 1068, in external_url
    if self.ingress.external_host:
  File "/var/lib/juju/agents/unit-grafana-0/charm/lib/charms/traefik_route_k8s/v0/traefik_route.py", line 220, in external_host
    self._update_stored_external_host()
  File "/var/lib/juju/agents/unit-grafana-0/charm/lib/charms/traefik_route_k8s/v0/traefik_route.py", line 235, in _update_stored_external_host
    external_host = relation.data[relation.app].get("external_host", "")
  File "/var/lib/juju/agents/unit-grafana-0/charm/venv/ops/model.py", line 914, in __getitem__
    raise KeyError(
KeyError: 'Cannot index relation data with "None". Are you trying to access remote app data during a relation-broken event? This is not allowed.'
unit-grafana-0: 00:56:32.564 ERROR juju.worker.uniter.operation hook "ingress-relation-broken" (via hook dispatching script: dispatch) failed: exit status 1

Additional context

No response

@PietroPasotti
Copy link
Contributor

should be fixed by canonical/traefik-route-k8s-operator#17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants