Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/service/core/config/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,11 @@ def update_backend(
username: The username of the user updating the backend.
"""
postgres = connectors.PostgresConnector.get_instance()
old_backend = connectors.Backend.fetch_from_db(postgres, name)
try:
old_backend = connectors.Backend.fetch_from_db(postgres, name)
except pydantic.error_wrappers.ValidationError as e:
logging.warning('Failed to get previous backend %s: %s', name, e)
old_backend = None
_update_backend_helper(postgres, configs_objects.BackendConfigWithName(
**request.configs.dict(), name=name))

Expand Down
8 changes: 8 additions & 0 deletions src/utils/connectors/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,13 @@ def set_default_values(configs: 'DynamicConfig', config_type: ConfigType):
ConfigHistoryType.BACKEND_TEST,
ConfigHistoryType.ROLE,
]:
fetch_cmd = """
SELECT * FROM config_history WHERE config_type = %s;
"""
data = self.execute_fetch_command(fetch_cmd, (config_type.value.lower(),))
if data:
continue

if config_type == ConfigHistoryType.SERVICE:
data = self.get_service_configs().plaintext_dict(
exclude_unset=True, by_alias=True
Expand Down Expand Up @@ -2140,6 +2147,7 @@ class BackendNodeConditions(pydantic.BaseModel):
rules: Dict[str, str] | None = None
prefix: str = 'osmo.nvidia.com/'


class Backend(pydantic.BaseModel):
""" Object storing backend info. """
name: str
Expand Down
4 changes: 2 additions & 2 deletions src/utils/job/kb_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import pydantic

from src.lib.utils import common as common_utils, priority as wf_priority
from src.lib.utils import common as common_utils, priority as wf_priority, osmo_errors
from src.utils.job import common, backend_job_defs
from src.utils import connectors

Expand Down Expand Up @@ -484,7 +484,7 @@ def get_k8s_object_factory(backend: connectors.Backend) -> K8sObjectFactory:
if scheduler_type == connectors.BackendSchedulerType.KAI:
return KaiK8sObjectFactory(backend)
else:
raise ValueError(f'Unsupported scheduler type: {scheduler_type}')
raise osmo_errors.OSMOServerError(f'Unsupported scheduler type: {scheduler_type}')


class FileMount(pydantic.BaseModel):
Expand Down