Skip to content
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

feat(BA-468): Add timeout conf for image push #3412

Merged
merged 2 commits into from
Jan 23, 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/3412.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add timeout configuration for Docker image push
9 changes: 6 additions & 3 deletions src/ai/backend/agent/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@
}

DEFAULT_PULL_TIMEOUT = 2 * 60 * 60 # 2 hours
DEFAULT_PUSH_TIMEOUT = None # Infinite

default_api_config = {
"pull-timeout": DEFAULT_PULL_TIMEOUT,
}
default_api_config = {"pull-timeout": DEFAULT_PULL_TIMEOUT, "push-timeout": DEFAULT_PUSH_TIMEOUT}

agent_etcd_config_iv = t.Dict({
t.Key("container-logs", default=default_container_logs_config): t.Dict({
Expand All @@ -163,6 +162,10 @@
t.Key("api", default=default_api_config): t.Dict({
t.Key("pull-timeout", default=default_api_config["pull-timeout"]): tx.ToNone
| t.ToFloat[0:], # Set the image pull timeout in seconds
t.Key("push-timeout", default=default_api_config["push-timeout"]): tx.ToNone
| t.ToFloat[
0:
], # Set the image push timeout in seconds. 'None' indicates an infinite timeout.
Comment on lines +165 to +168
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn’t seem right to have the push-timeout value under the api section.

Copy link
Collaborator

Choose a reason for hiding this comment

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

However, since the existing pull-timeout is also in the same location, it seems like this will require a follow-up task to reorganize the config structure.

}).allow_extra("*"),
}).allow_extra("*")

Expand Down
6 changes: 5 additions & 1 deletion src/ai/backend/agent/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,15 @@ async def push_image(
log.info("rpc::push_image(c:{})", image_ref.canonical)
bgtask_mgr = self.agent.background_task_manager

image_push_timeout = cast(
Optional[float], self.local_config["agent"]["api"]["push-timeout"]
)
Comment on lines +818 to +820
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is type casting necessary? Can’t we set the timeout value stored in local_config as Optional[float]?

Copy link
Member Author

Choose a reason for hiding this comment

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

the value is stored as Optional[float]. I used typing.cast to specify the expected type of the value to the type checker


async def _push_image(reporter: ProgressReporter) -> None:
await self.agent.push_image(
image_ref,
registry_conf,
timeout=None,
timeout=image_push_timeout,
)

task_id = await bgtask_mgr.start(_push_image)
Expand Down
Loading