Skip to content

Mongo unit error state on teardown #218

@markbeierl

Description

@markbeierl

Steps to reproduce

Destroy a model with multiple applications relationed to mongodb-k8s.

Expected behavior

Model tears down cleanly

Actual behavior

Mongo charm goes into error state. The following is observed in the juju debug-log:

Versions

Operating system: Ubuntu 22.04.3 LTS
Juju CLI: 3.1.7-genericlinux-amd64
Juju agent: 3.1.7
Charm revision: 5/edge 36
microk8s: MicroK8s v1.27.7 revision 6101

Log output

Juju debug log:
log.txt

unit-mongodb-k8s-0: 20:46:42 INFO unit.mongodb-k8s/0.juju-log database:15: Update relation user: relation-7 on free5gc
unit-mongodb-k8s-0: 20:46:42 INFO unit.mongodb-k8s/0.juju-log database:15: Updating relation data according to diff
unit-mongodb-k8s-0: 20:46:42 ERROR unit.mongodb-k8s/0.juju-log database:15: Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/./src/charm.py", line 1218, in <module>
    main(MongoDBCharm)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/venv/ops/main.py", line 441, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/venv/ops/main.py", line 149, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/venv/ops/framework.py", line 344, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/venv/ops/framework.py", line 833, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/venv/ops/framework.py", line 922, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/lib/charms/mongodb/v0/mongodb_provider.py", line 97, in _on_relation_event
    self.oversee_users(departed_relation_id, event)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/lib/charms/mongodb/v0/mongodb_provider.py", line 149, in oversee_users
    self._diff(event)
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/lib/charms/mongodb/v0/mongodb_provider.py", line 175, in _diff
    key: value for key, value in event.relation.data[event.app].items() if key != "data"
  File "/var/lib/juju/agents/unit-mongodb-k8s-0/charm/venv/ops/model.py", line 1361, 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-mongodb-k8s-0: 20:46:42 ERROR juju.worker.uniter.operation hook "database-relation-broken" (via hook dispatching script: dispatch) failed: exit status 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions