mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-02 07:37:14 +00:00
fix(cloud): skip legacy model sync during startup
This commit is contained in:
@@ -161,9 +161,14 @@ class ModelManager:
|
|||||||
self.ap.logger.info('LangBot Space Models service is disabled, skipping sync.')
|
self.ap.logger.info('LangBot Space Models service is disabled, skipping sync.')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Space model synchronization is a legacy OSS-singleton facility. A
|
# Space model synchronization is a legacy OSS-singleton facility. Cloud
|
||||||
# cloud instance must receive tenant model projections from its control
|
# receives tenant model projections from its control plane and must not
|
||||||
# plane and must never infer one Workspace for this global operation.
|
# resolve an OSS-local Workspace outside a tenant-scoped unit of work.
|
||||||
|
cloud_runtime = getattr(getattr(self.ap.persistence_mgr, 'mode', None), 'value', None) == 'cloud_runtime'
|
||||||
|
if cloud_runtime:
|
||||||
|
self.ap.logger.info('Skipping legacy LangBot Space model sync in Cloud Runtime.')
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
binding = await self.ap.workspace_service.get_local_execution_binding()
|
binding = await self.ap.workspace_service.get_local_execution_binding()
|
||||||
except WorkspaceError as exc:
|
except WorkspaceError as exc:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ and error handling without calling real LLM APIs.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from types import SimpleNamespace
|
||||||
from unittest.mock import AsyncMock, Mock
|
from unittest.mock import AsyncMock, Mock
|
||||||
|
|
||||||
from langbot.pkg.provider.modelmgr.modelmgr import ModelManager
|
from langbot.pkg.provider.modelmgr.modelmgr import ModelManager
|
||||||
@@ -70,6 +71,20 @@ async def test_model_manager_skips_space_sync_when_disabled(mock_app_for_modelmg
|
|||||||
app.space_service.get_models.assert_not_called()
|
app.space_service.get_models.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_model_manager_skips_legacy_space_sync_in_cloud_runtime(mock_app_for_modelmgr):
|
||||||
|
"""Cloud startup must not resolve an OSS-local Workspace for legacy model sync."""
|
||||||
|
app = mock_app_for_modelmgr
|
||||||
|
app.instance_config.data = {'space': {'disable_models_service': False}}
|
||||||
|
app.persistence_mgr.mode = SimpleNamespace(value='cloud_runtime')
|
||||||
|
|
||||||
|
model_mgr = ModelManager(app)
|
||||||
|
model_mgr.load_models_from_db = AsyncMock()
|
||||||
|
await model_mgr.initialize()
|
||||||
|
|
||||||
|
app.workspace_service.get_local_execution_binding.assert_not_awaited()
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Model Loading Tests
|
# Model Loading Tests
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user