canonical / canonical/wordpress-k8s-operator

metadata.yaml doesn't set a limit on database relations

Open
#336 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16
Forks
15
Avg merge
1d 22h
Merged PRs (30d)
2

Description

### Bug Description

it's possible to relate multiple databases to the databases endpoint, leading to `hook failed: storage-attached`

### To Reproduce

deploy with mysql-router and mysql and relate both to the database endpoint

### Environment

https://test-observer.canonical.com/#/charms/275993?testExecutionId=287586&testResultId=7944781

### Relevant log output

```shell
2025-11-18T16:04:19.264Z [container-agent] 2025-11-18 16:04:19 DEBUG jujuc server.go:302 running hook tool "juju-log" for target/0-uploads-storage-attached-7ce6e585ee5de350da0010ccd0fe6552
2025-11-18T16:04:19.264Z [container-agent] 2025-11-18 16:04:19 ERROR juju-log Uncaught exception while in charm code:
2025-11-18T16:04:19.264Z [container-agent] Traceback (most recent call last):
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/./src/charm.py", line 1580, in
2025-11-18T16:04:19.264Z [container-agent] main(WordpressCharm)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/main.py", line 39, in main
2025-11-18T16:04:19.264Z [container-agent] return _main.main(charm_class=charm_class, use_juju_for_storage=use_juju_for_storage)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/_main.py", line 504, in main
2025-11-18T16:04:19.264Z [container-agent] manager.run()
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/_main.py", line 488, in run
2025-11-18T16:04:19.264Z [container-agent] self._emit()
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/_main.py", line 423, in _emit
2025-11-18T16:04:19.264Z [container-agent] self._emit_charm_event(self.dispatcher.event_name)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/_main.py", line 467, in _emit_charm_event
2025-11-18T16:04:19.264Z [container-agent] event_to_emit.emit(*args, **kwargs)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/framework.py", line 351, in emit
2025-11-18T16:04:19.264Z [container-agent] framework._emit(event)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/framework.py", line 924, in _emit
2025-11-18T16:04:19.264Z [container-agent] self._reemit(event_path)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/framework.py", line 1036, in _reemit
2025-11-18T16:04:19.264Z [container-agent] custom_handler(event)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/./src/charm.py", line 1565, in _reconciliation
2025-11-18T16:04:19.264Z [container-agent] self._core_reconciliation()
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/./src/charm.py", line 924, in _core_reconciliation
2025-11-18T16:04:19.264Z [container-agent] if not self._current_effective_db_info:
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/./src/charm.py", line 675, in _current_effective_db_info
2025-11-18T16:04:19.264Z [container-agent] relation = self.model.get_relation(self._DATABASE_RELATION_NAME)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/model.py", line 277, in get_relation
2025-11-18T16:04:19.264Z [container-agent] return self.relations._get_unique(relation_name, relation_id)
2025-11-18T16:04:19.264Z [container-agent] File "/var/lib/juju/agents/unit-target-0/charm/venv/ops/model.py", line 1025, in _get_unique
2025-11-18T16:04:19.264Z [container-agent] raise TooManyRelatedAppsError(relation_name, num_related, 1)
2025-11-18T16:04:19.264Z [container-agent] ops.model.TooManyRelatedAppsError: Too many remote applications on database (2 > 1)
```

### Additional context

Part of the charm qa testing effort

Contributor guide

Open the contributing guide

Research direction

Inspect the database endpoint declaration in metadata.yaml and compare it with the reproduction using mysql-router and mysql. Deploy the charm with both relations and verify that the relation limit prevents the storage-attached hook failure caused by multiple remote applications.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.