Skip to content

Commit

Permalink
Fix logger exception on instance provisioning timeout (#1697)
Browse files Browse the repository at this point in the history
Fixes: #1696
  • Loading branch information
un-def authored Sep 18, 2024
1 parent 47cd180 commit 958a292
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ async def _add_remote(instance: InstanceModel) -> None:
) + timedelta(seconds=PROVISIONING_TIMEOUT_SECONDS)
if retry_duration_deadline < get_current_datetime():
instance.status = InstanceStatus.TERMINATED
instance.termination_reason = "Proivisioning timeout expired"
instance.termination_reason = "Provisioning timeout expired"
logger.warning(
"Failed to start instance in %s seconds. Terminating...",
PROVISIONING_TIMEOUT_SECONDS,
"Failed to start instance %s in %d seconds. Terminating...",
instance.name,
PROVISIONING_TIMEOUT_SECONDS,
extra={
"instance_name": instance.name,
"instance_status": InstanceStatus.TERMINATED.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,29 @@ async def test_terminate_by_idle_timeout(self, test_db, session: AsyncSession):
assert instance.termination_reason == "Idle timeout"


class TestOnPremInstanceTerminateProvisionTimeoutExpired:
@pytest.mark.asyncio
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
async def test_terminate_by_idle_timeout(self, test_db, session: AsyncSession):
project = await create_project(session=session)
pool = await create_pool(session, project)
instance = await create_instance(
session,
project,
pool,
status=InstanceStatus.PENDING,
created_at=get_current_datetime() - dt.timedelta(days=100),
)
instance.remote_connection_info = "{}"
await session.commit()

await process_instances()

await session.refresh(instance)
assert instance.status == InstanceStatus.TERMINATED
assert instance.termination_reason == "Provisioning timeout expired"


class TestTerminate:
@pytest.mark.asyncio
@pytest.mark.parametrize("test_db", ["sqlite", "postgres"], indirect=True)
Expand Down

0 comments on commit 958a292

Please sign in to comment.