Skip to content

Commit ccf4b47

Browse files
committed
show warning when DB port is not yet available
1 parent e5ad755 commit ccf4b47

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/api/organization/project/branch/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ async def _persist_branch_status(branch_id: Identifier, status: BranchServiceSta
158158
await session.commit()
159159

160160

161-
async def _get_branch_db_port(branch: Branch) -> int:
161+
async def _get_branch_db_port(branch: Branch) -> int | None:
162162
if branch.db_port is not None:
163163
return branch.db_port
164164
port = await _resolve_branch_db_port(branch.id)
165165
if port is None:
166-
raise VelaKubernetesError(f"Could not resolve db port for branch {branch.id}")
166+
return None
167167
async with AsyncSessionLocal() as session:
168168
db_branch = await session.get(Branch, branch.id)
169169
if db_branch is not None:
@@ -1025,6 +1025,8 @@ async def _public(branch: Branch) -> BranchPublic:
10251025

10261026
db_host = _resolve_db_host(branch) or ""
10271027
port = await _get_branch_db_port(branch)
1028+
if port is None:
1029+
logger.warning("db port not yet available for branch %s", branch.id)
10281030

10291031
# pg-meta and pg are in the same network. So password is not required in connection string.
10301032
connection_string = _build_connection_string("vela", "postgres", 5432)

src/models/branch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def __new__(cls, value: str, description: str):
353353

354354
class DatabaseInformation(BaseModel):
355355
host: str
356-
port: int
356+
port: int | None
357357
username: str
358358
name: str
359359
encrypted_connection_string: str

0 commit comments

Comments
 (0)