canonical / traefik-k8s-operator

This charmed operator automates the operational procedures of running Traefik, an open-source application proxy.
https://charmhub.io/traefik-k8s
Apache License 2.0
11 stars 25 forks source link

hook failed: "ingress-per-unit-relation-broken" #158

Closed sed-i closed 1 year ago

sed-i commented 1 year ago

Two kinds of errors on "ingress-per-unit-relation-broken" in the latest revision of traefik (123) still persist after #151 :

1

https://github.com/canonical/traefik-k8s-operator/blob/34a0aa5ca57bf2d2200a37d3f884b8a13b0d4920/src/charm.py#L875

errors with:

unit-trfk-0: 15:03:32.368 DEBUG unit.trfk/0.juju-log ingress-per-unit:8: Wiping the ingress setup for the 'ingress-per-unit:8' relation
unit-trfk-0: 15:03:32.373 ERROR unit.trfk/0.juju-log ingress-per-unit:8: Uncaught exception while in charm code:
Traceback (most recent call last):
  File "./src/charm.py", line 1024, in <module>
    main(TraefikIngressCharm, use_juju_for_storage=True)
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/main.py", line 441, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/main.py", line 149, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/framework.py", line 354, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/framework.py", line 830, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/framework.py", line 919, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-trfk-0/charm/lib/charms/traefik_k8s/v1/ingress_per_unit.py", line 340, in _handle_relation_broken
    self.on.data_removed.emit(event.relation)  # type: ignore
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/framework.py", line 354, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/framework.py", line 830, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-trfk-0/charm/venv/ops/framework.py", line 919, in _reemit
    custom_handler(event)
  File "./src/charm.py", line 579, in _handle_ingress_data_removed
    self._wipe_ingress_for_relation(
  File "./src/charm.py", line 856, in _wipe_ingress_for_relation
    config_path = f"{_DYNAMIC_CONFIG_DIR}/{self._relation_config_file(relation)}"
  File "./src/charm.py", line 875, in _relation_config_file
    assert relation.app, "no app in relation (shouldn't happen)"  # for type checker
AssertionError: no app in relation (shouldn't happen)

2

In Loki (latest revision, 79), the lib is not up to date (did we publish-lib here?)

https://github.com/canonical/traefik-k8s-operator/blob/34a0aa5ca57bf2d2200a37d3f884b8a13b0d4920/lib/charms/traefik_k8s/v1/ingress_per_unit.py#L804

errors with:

unit-loki2-0: 15:03:16.040 ERROR juju.worker.uniter.operation hook "ingress-relation-broken" (via hook dispatching script: dispatch) failed: exit status 1
unit-loki2-1: 15:03:16.064 ERROR unit.loki2/1.juju-log ingress:8: Uncaught exception while in charm code:
Traceback (most recent call last):
  File "./src/charm.py", line 541, in <module>
    main(LokiOperatorCharm, use_juju_for_storage=True)
  File "/var/lib/juju/agents/unit-loki2-1/charm/venv/ops/main.py", line 429, in main
    charm = charm_class(framework)
  File "./src/charm.py", line 103, in __init__
    source_url=self._external_url,
  File "./src/charm.py", line 219, in _external_url
    if ingress_url := self.ingress_per_unit.url:
  File "/var/lib/juju/agents/unit-loki2-1/charm/lib/charms/traefik_k8s/v1/ingress_per_unit.py", line 843, in url
    urls = self.urls
  File "/var/lib/juju/agents/unit-loki2-1/charm/lib/charms/traefik_k8s/v1/ingress_per_unit.py", line 834, in urls
    current_urls = self._urls_from_relation_data
  File "/var/lib/juju/agents/unit-loki2-1/charm/lib/charms/traefik_k8s/v1/ingress_per_unit.py", line 804, in _urls_from_relation_data
    if not relation.app and not relation.app.name:  # type: ignore
AttributeError: 'NoneType' object has no attribute 'name'
PietroPasotti commented 1 year ago

Interesting. Hadn't we fixed the second one though?