Skip to content

Commit

Permalink
fix: explicitly apply minio-service with name (#151)
Browse files Browse the repository at this point in the history
* fix: explicitly apply minio-service with name

The upstream pipelines project hardcodes the name of the
object storage service to minio-service. The current implementation
sets the service to just minio, which collides with what pipelines
expect. This PR ensures the Service is created with the expected
name and ports.
Refer to kubeflow/pipelines#9689 for more information
  • Loading branch information
DnPlas authored Oct 17, 2023
1 parent f7bdcf0 commit b99aad8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
31 changes: 29 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
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()
Expand Down Expand Up @@ -121,7 +126,29 @@ 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"]),
},
],
},
},
],
},
}

Expand Down Expand Up @@ -165,7 +192,7 @@ def _send_info(self, interfaces, secret_key):
"port": self.model.config["port"],
"secret-key": secret_key,
"secure": False,
"service": self.model.app.name,
"service": MINIO_SERVICE,
}
)

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ops.model import ActiveStatus, BlockedStatus, WaitingStatus
from ops.testing import Harness

from charm import Operator
from charm import MINIO_SERVICE, Operator


@pytest.fixture
Expand Down Expand Up @@ -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"
assert data["service"] == MINIO_SERVICE


def test_main_with_manual_secret(harness):
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_main_with_manual_secret(harness):
"port": 9000,
"secret-key": "test-key",
"secure": False,
"service": "minio",
"service": MINIO_SERVICE,
}
assert harness.charm.model.unit.status == ActiveStatus("")

Expand Down

0 comments on commit b99aad8

Please sign in to comment.