Skip to content

feat(BA-695): Configurable setup for kernel initialization polling #3657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025
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
1 change: 1 addition & 0 deletions changes/3657.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add configurable setup for kernel initialization polling
12 changes: 11 additions & 1 deletion src/ai/backend/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2227,10 +2227,20 @@ async def create_kernel(
current_task = asyncio.current_task()
assert current_task is not None
self._pending_creation_tasks[kernel_id].add(current_task)
kernel_init_polling_attempt = cast(
int, self.local_config["agent"]["kernel-lifecycles"]["init-polling-attempt"]
)
kernel_init_polling_timeout = cast(
float,
self.local_config["agent"]["kernel-lifecycles"]["init-polling-timeout-sec"],
)
try:
async for attempt in AsyncRetrying(
wait=wait_fixed(0.3),
stop=(stop_after_attempt(10) | stop_after_delay(60)),
stop=(
stop_after_attempt(kernel_init_polling_attempt)
| stop_after_delay(kernel_init_polling_timeout)
),
retry=retry_if_exception_type(zmq.error.ZMQError),
):
with attempt:
Expand Down
17 changes: 17 additions & 0 deletions src/ai/backend/agent/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,15 @@

DEFAULT_PULL_TIMEOUT = 2 * 60 * 60 # 2 hours
DEFAULT_PUSH_TIMEOUT = None # Infinite
DEFAULT_KERNEL_INIT_POLLING_ATTEMPT = 10
DEFAULT_KERNEL_INIT_POLLING_TIMEOUT = 60.0 # 60 seconds
Comment on lines +174 to +175
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you decide to set the default timeout at 30 minutes?


default_api_config = {"pull-timeout": DEFAULT_PULL_TIMEOUT, "push-timeout": DEFAULT_PUSH_TIMEOUT}
default_kernel_lifecycles = {
"init-polling-attempt": DEFAULT_KERNEL_INIT_POLLING_ATTEMPT,
"init-polling-timeout-sec": DEFAULT_KERNEL_INIT_POLLING_TIMEOUT,
}


agent_etcd_config_iv = t.Dict({
t.Key("container-logs", default=default_container_logs_config): t.Dict({
Expand All @@ -187,6 +194,16 @@
0:
], # Set the image push timeout in seconds. 'None' indicates an infinite timeout.
}).allow_extra("*"),
t.Key("kernel-lifecycles", default=default_kernel_lifecycles): t.Dict({
t.Key(
"init-polling-attempt",
default=default_kernel_lifecycles["init-polling-attempt"],
): t.ToInt,
t.Key(
"init-polling-timeout-sec",
default=default_kernel_lifecycles["init-polling-timeout-sec"],
): t.ToFloat,
}),
}).allow_extra("*")

container_etcd_config_iv = t.Dict({
Expand Down
Loading