diff --git a/src/charm.py b/src/charm.py index 73ec07e7..c5c430bc 100755 --- a/src/charm.py +++ b/src/charm.py @@ -59,6 +59,9 @@ PFCP_PORT = 8805 REQUIRED_CPU_EXTENSIONS = ["avx2", "rdrand"] +# The default field manager set when using kubectl to create resources +DEFAULT_FIELD_MANAGER = "controller" + class IncompatibleCPUError(Exception): """Custom error to be raised when CPU doesn't support required instructions.""" @@ -168,8 +171,8 @@ def _create_external_upf_service(self) -> None: ), ) - client.create(service) - logger.info("Created external UPF service") + client.apply(service, field_manager=DEFAULT_FIELD_MANAGER) + logger.info("Created/asserted existence of the external UPF service") def _on_remove(self, event: RemoveEvent) -> None: self._delete_external_upf_service() diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 6411d997..40dfc37b 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -693,7 +693,9 @@ def test_when_install_then_external_service_is_created(self, patch_client): ), ) - patch_client.return_value.create.assert_called_once_with(expected_service) + patch_client.return_value.apply.assert_called_once_with( + expected_service, field_manager="controller" + ) @patch("charm.Client") def test_when_remove_then_external_service_is_deleted(self, patch_client):