canonical / oathkeeper-operator

Charmed Ory Oathkeeper
https://charmhub.io/oathkeeper
Apache License 2.0
1 stars 4 forks source link

Requirer charm goes into error state on removal #44

Closed sed-i closed 7 months ago

sed-i commented 9 months ago

Bug Description

When remove oathkeeper relation, zinc went into error state.

To Reproduce

Deploy the following bundle, and then juju remove-application ok trfk zinc.

bundle: kubernetes
applications:
  ok:
    # From https://github.com/canonical/oathkeeper-operator
    # 1e23771 - (HEAD -> address-forward-auth-comments, origin/address-forward-auth-comments) refactor
    charm: ./oathkeeper-operator/oathkeeper_ubuntu-22.04-amd64.charm
    scale: 1
    constraints: arch=amd64
    trust: true
    resources:
      oci-image: "ghcr.io/canonical/oathkeeper:0.40.6"
    options:
      # until tls is impl'd dev mode would resort to http decisions url
      dev: true
  trfk:
    # From https://github.com/canonical/traefik-k8s-operator/pull/275
    # cc35a85 - (HEAD -> IAM-500-forward-auth-relation-implementation, natalian98/IAM-500-forward-auth-relation-implementation) refactor: add experimental_forward_auth_enabled as an init arg
    charm: ./traefik-k8s-operator/traefik-k8s_ubuntu-20.04-amd64.charm
    series: focal
    scale: 1
    constraints: arch=amd64
    storage:
      configurations: kubernetes,1,1024M
    trust: true
    resources:
      traefik-image: "docker.io/ubuntu/traefik:2-22.04"
    options:
      enable_experimental_forward_auth: true
  zinc:
    # From https://github.com/natalian98/zinc-k8s-operator
    # 0c19865 - (HEAD -> test-proxy-interfaces, origin/test-proxy-interfaces) fix: auth-proxy
    charm: ./zinc-k8s-operator/zinc-k8s_ubuntu-22.04-amd64.charm
    scale: 1
    constraints: arch=amd64
    storage:
      data: kubernetes,1,1024M
    trust: true
    resources:
      zinc-image: "ghcr.io/jnsgruk/zinc:0.4.9"
relations:
- - ok:forward-auth
  - trfk:experimental-forward-auth
- - ok:auth-proxy
  - zinc:auth-proxy
- - zinc:ingress
  - trfk:ingress

Environment

Model  Controller  Cloud/Region        Version  SLA          Timestamp
auth2  k8s2        microk8s/localhost  3.1.6    unsupported  23:27:07-05:00

App   Version  Status   Scale  Charm           Channel  Rev  Address         Exposed  Message
ok             unknown      0  oathkeeper                 3  10.152.183.181  no       
trfk           unknown      0  traefik-k8s                2  10.43.8.206     no       
zinc  ...      error      1/0  zinc-k8s                   2  10.152.183.134  no       hook failed: "auth-proxy-relation-departed"

Unit     Workload  Agent  Address       Ports  Message     
zinc/0*  error     idle   10.1.166.106         hook failed: "auth-proxy-relation-departed" for ok:auth-proxy

Relevant log output

unit-zinc-0: 23:22:24.558 DEBUG unit.zinc/0.juju-log auth-proxy:21: Emitting Juju event auth_proxy_relation_departed.
unit-zinc-0: 23:22:24.567 ERROR unit.zinc/0.juju-log auth-proxy:21: Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-zinc-0/charm/./src/charm.py", line 132, in <module>
    ops.main(ZincCharm)
  File "/var/lib/juju/agents/unit-zinc-0/charm/venv/ops/main.py", line 456, in __call__
    return main(charm_class, use_juju_for_storage=use_juju_for_storage)
  File "/var/lib/juju/agents/unit-zinc-0/charm/venv/ops/main.py", line 441, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-zinc-0/charm/venv/ops/main.py", line 149, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-zinc-0/charm/venv/ops/framework.py", line 344, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-zinc-0/charm/venv/ops/framework.py", line 841, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-zinc-0/charm/venv/ops/framework.py", line 930, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-zinc-0/charm/lib/charms/oathkeeper/v0/auth_proxy.py", line 440, in _on_relation_departed_event
    self._pop_relation_data(event.relation.id)
  File "/var/lib/juju/agents/unit-zinc-0/charm/lib/charms/oathkeeper/v0/auth_proxy.py", line 165, in _pop_relation_data
    if not self._charm.model.relations[self._relation_name]:
AttributeError: 'AuthProxyRequirer' object has no attribute '_charm'
unit-zinc-0: 23:22:24.784 ERROR juju.worker.uniter.operation hook "auth-proxy-relation-departed" (via hook dispatching script: dispatch) failed: exit status 1

Additional context

No response

syncronize-issues-to-jira[bot] commented 7 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/IAM-654.

This message was autogenerated