diff --git a/src/charm.py b/src/charm.py index 56e2011..38d083f 100755 --- a/src/charm.py +++ b/src/charm.py @@ -17,11 +17,6 @@ from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus, WaitingStatus from serialized_data_interface import NoCompatibleVersions, NoVersionsListed, get_interfaces -# The name of the minio service is hardcoded in the -# object store source code of pipelines as "minio-service" -# See https://github.com/kubeflow/pipelines/issues/9689 for more information -MINIO_SERVICE = "minio-service" - class Operator(CharmBase): _stored = StoredState() @@ -33,6 +28,8 @@ def __init__(self, *args): # Random salt used for hashing config self._stored.set_default(hash_salt=_gen_pass()) + self._minio_service_name = self.app.name + self.image = OCIImageResource(self, "oci-image") self.prometheus_provider = MetricsEndpointProvider( @@ -126,29 +123,7 @@ def main(self, event): }.items() }, }, - ], - "services": [ - { - "name": MINIO_SERVICE, - "spec": { - "selector": {"app.kubernetes.io/name": self.model.app.name}, - "ports": [ - { - "name": "minio", - "port": int(self.model.config["port"]), - "protocol": "TCP", - "targetPort": int(self.model.config["port"]), - }, - { - "name": "console", - "port": int(self.model.config["console-port"]), - "protocol": "TCP", - "targetPort": int(self.model.config["console-port"]), - }, - ], - }, - }, - ], + ] }, } @@ -192,7 +167,7 @@ def _send_info(self, interfaces, secret_key): "port": self.model.config["port"], "secret-key": secret_key, "secure": False, - "service": MINIO_SERVICE, + "service": self._minio_service_name, } ) diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 1d25892..d4f3a0b 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -9,7 +9,7 @@ from ops.model import ActiveStatus, BlockedStatus, WaitingStatus from ops.testing import Harness -from charm import MINIO_SERVICE, Operator +from charm import Operator @pytest.fixture @@ -119,7 +119,7 @@ def test_main_with_relation(harness): assert data["port"] == 9000 assert data["secure"] is False assert len(data["secret-key"]) == 30 - assert data["service"] == MINIO_SERVICE + assert data["service"] == "minio" def test_main_with_manual_secret(harness): @@ -150,7 +150,7 @@ def test_main_with_manual_secret(harness): "port": 9000, "secret-key": "test-key", "secure": False, - "service": MINIO_SERVICE, + "service": "minio", } assert harness.charm.model.unit.status == ActiveStatus("")