diff --git a/changelog/current.md b/changelog/current.md index 6436a6d7d..462aa9483 100644 --- a/changelog/current.md +++ b/changelog/current.md @@ -6,6 +6,7 @@ Record image-affecting changes to `manager/`, `worker/`, `copaw/`, `hermes/`, `o **Bug Fixes** +- **CoPaw k8s worker static alias fallback**: When running in local K8s with self-hosted MinIO, `_ensure_alias()` now falls through to static `mc alias set` if `MC_HOST_{alias}` is not already set by the cloud STS path. Fixes #957. - **Team Worker room boundary convergence**: Remove Manager again after standalone Worker infrastructure reconciliation restores regular Team Worker personal-room membership. ([b5b0add](https://github.com/agentscope-ai/AgentTeams/commit/b5b0add)) - **Team Worker reference enforcement**: Keep referenced Worker CRs protected during direct deletion and reject Team API members whose required role is empty. ([d96f1ed](https://github.com/agentscope-ai/AgentTeams/commit/d96f1ed)) - **Team Worker room membership**: Force Manager out of regular Team Worker personal rooms when equal Matrix power levels prevent a normal kick. ([43545c2](https://github.com/agentscope-ai/AgentTeams/commit/43545c2)) diff --git a/copaw/src/copaw_worker/sync.py b/copaw/src/copaw_worker/sync.py index 74f0c3241..20c82232e 100644 --- a/copaw/src/copaw_worker/sync.py +++ b/copaw/src/copaw_worker/sync.py @@ -320,9 +320,17 @@ def _ensure_alias(self) -> None: controller_url, ) if self._k8s_mode: - logger.info("_ensure_alias: k8s mode, skipping mc alias set (mc-wrapper handles credentials)") - self._alias_set = True - return + if mc_host_set: + logger.info( + "_ensure_alias: k8s mode, MC_HOST_%s already set (cloud STS), skipping mc alias set", + _MC_ALIAS, + ) + self._alias_set = True + return + logger.info( + "_ensure_alias: k8s mode, MC_HOST_%s not set (local MinIO), falling through to static alias setup", + _MC_ALIAS, + ) if self._cloud_mode: logger.info("_ensure_alias: credential path=sts, refreshing MC_HOST_%s", _MC_ALIAS) self._refresh_cloud_credentials() diff --git a/copaw/tests/test_sync.py b/copaw/tests/test_sync.py index f8b763ec4..f6c009798 100644 --- a/copaw/tests/test_sync.py +++ b/copaw/tests/test_sync.py @@ -527,3 +527,29 @@ async def test_push_loop_reports_bridge_failure_as_bridge_health(tmp_path, monke assert message == "runtime-to-standard bridge failed: runtime bridge failed" assert details["operation"] == "bridge_runtime_to_standard" assert details["error_type"] == "BridgeRuntimeError" + + +def test_ensure_alias_k8s_with_mc_host_set_skips_static(monkeypatch, tmp_path): + monkeypatch.setenv("AGENTTEAMS_RUNTIME", "k8s") + monkeypatch.setenv("MC_HOST_agentteams", "http://key:secret@minio:9000") + sync = _sync(tmp_path) + sync._ensure_alias() + assert sync._alias_set is True + + +def test_ensure_alias_k8s_without_mc_host_falls_through_static(monkeypatch, tmp_path): + monkeypatch.setenv("AGENTTEAMS_RUNTIME", "k8s") + monkeypatch.delenv("MC_HOST_agentteams", raising=False) + sync = _sync(tmp_path) + monkeypatch.setattr("copaw_worker.sync._mc", lambda *_args, **_kwargs: None) + sync._ensure_alias() + assert sync._alias_set is True + + +def test_ensure_alias_non_k8s_uses_static(monkeypatch, tmp_path): + monkeypatch.delenv("AGENTTEAMS_RUNTIME", raising=False) + monkeypatch.delenv("MC_HOST_agentteams", raising=False) + sync = _sync(tmp_path) + monkeypatch.setattr("copaw_worker.sync._mc", lambda *_args, **_kwargs: None) + sync._ensure_alias() + assert sync._alias_set is True