operator icon indicating copy to clipboard operation
operator copied to clipboard

RuntimeError: override: "merge" unsupported for layer

Open alesstimec opened this issue 3 years ago • 1 comments

Hi,

Working on a k8s for JIMM charm i found the following issue when trying to run test:

ERROR: test_on_config_changed (tests.test_charm.TestCharm)

Traceback (most recent call last): File "/home/alesstimec/Canonical/go/src/github.com/CanonicalLtd/jimm/jimm-operator/tests/test_charm.py", line 71, in test_on_config_changed self.harness.charm.on.jimm_pebble_ready.emit(container) File "/home/alesstimec/.local/lib/python3.10/site-packages/ops/framework.py", line 283, in emit framework._emit(event) File "/home/alesstimec/.local/lib/python3.10/site-packages/ops/framework.py", line 743, in _emit self._reemit(event_path) File "/home/alesstimec/.local/lib/python3.10/site-packages/ops/framework.py", line 790, in _reemit custom_handler(event) File "/home/alesstimec/Canonical/go/src/github.com/CanonicalLtd/jimm/jimm-operator/src/charm.py", line 79, in _on_jimm_pebble_ready self._update_workload(args, event) File "/home/alesstimec/Canonical/go/src/github.com/CanonicalLtd/jimm/jimm-operator/src/charm.py", line 213, in _update_workload container.add_layer("jimm", pebble_layer, combine=True) File "/home/alesstimec/.local/lib/python3.10/site-packages/ops/model.py", line 1188, in add_layer self._pebble.add_layer(label, layer, combine=combine) File "/home/alesstimec/.local/lib/python3.10/site-packages/ops/testing.py", line 1522, in add_layer raise RuntimeError( RuntimeError: override: "merge" unsupported for layer "jimm" service "jimm"

Now, when i deployed the charm in microk8s, the merge worked as expected. But it appears the test harness does not support "merge".

alesstimec avatar Apr 08 '22 08:04 alesstimec

Supporting this in the harness basically amounts to reimplementing this func in python: https://github.com/canonical/pebble/blob/master/internal/plan/plan.go#L120 Shouldn't be too hard. I'd delegate this task to someone else, except there's only me :joy:

rwcarlsen avatar Apr 12 '22 19:04 rwcarlsen

Support for merge in the harness was added in 1.5.0, see https://github.com/canonical/operator/commit/e3bc30bf8491716d33c8bb6061eb63bd8306ca1d

benhoyt avatar Jan 12 '23 02:01 benhoyt