canonical / opensearch-operator

OpenSearch operator
Apache License 2.0
13 stars 7 forks source link

Peer data relation delete fails at `remove-application` #379

Closed phvalguima closed 3 months ago

phvalguima commented 3 months ago

When removing a single unit with remove-application, it will cause:

Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-opensearch-0/charm/./src/charm.py", line 213, in <module>
    main(OpenSearchOperatorCharm)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/venv/ops/main.py", line 548, in main
    manager.run()
  File "/var/lib/juju/agents/unit-opensearch-0/charm/venv/ops/main.py", line 527, in run
    self._emit()
  File "/var/lib/juju/agents/unit-opensearch-0/charm/venv/ops/main.py", line 516, in _emit
    _emit_charm_event(self.charm, self.dispatcher.event_name)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/venv/ops/main.py", line 147, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/venv/ops/framework.py", line 348, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/venv/ops/framework.py", line 860, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/venv/ops/framework.py", line 950, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/lib/charms/opensearch/v0/opensearch_base_charm.py", line 495, in _on_opensearch_data_storage_detaching
    self.peers_data.delete(Scope.APP, "bootstrap_contributors_count")
  File "/var/lib/juju/agents/unit-opensearch-0/charm/lib/charms/opensearch/v0/opensearch_internal_data.py", line 182, in delete
    self.put(scope, key, None)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/lib/charms/opensearch/v0/opensearch_internal_data.py", line 115, in put
    self.put_or_delete(data, key, value)
  File "/var/lib/juju/agents/unit-opensearch-0/charm/lib/charms/opensearch/v0/opensearch_internal_data.py", line 94, in put_or_delete
    del data[key]
KeyError: 'bootstrap_contributors_count'

As the peer relation does not exist anymore.

github-actions[bot] commented 3 months ago

https://warthogs.atlassian.net/browse/DPE-4983