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

timeouts too low for some actions #165

Open
sjoerdsimons opened this issue Aug 12, 2021 · 13 comments
Open

timeouts too low for some actions #165

sjoerdsimons opened this issue Aug 12, 2021 · 13 comments
Labels
help wanted Extra attention is needed

Comments

@sjoerdsimons
Copy link

The bollard API only seems to have one general timeout for all of the client actions (2 minutes by default, or user provided when using connect_with_unix directly).

As always, timeouts are awkward (it's rougly impossible to get them right for all situations). But in this case that same timeout is used for all actions. Some you would hope are always fastish (e.g. listing running containers). However some can take a long while e.g. pulling a big image on a slow connection.

I'm unsure what a good solution is here; For now i'm working around it in client code by just setting the timeout to a day... But i guess the options roughly would be:

  • Make timeouts more fine-grained (e.g. ability to specify per action/call or seperate api calls in groups depending on expectations)
  • Add ability to simply disable timeouts in bollard, moving the responsibility to client code (or even removing timeouts in bollard itself entirely always making it the callers responsibility)
@fussybeaver
Copy link
Owner

Interesting question, thanks for raising it..

I'm a bit wary about indefinite timeouts - if the registry you're pulling from is down, you might get a hanging process. I'm not convinced that consumers of the library would do the sensible thing and create their own timeouts.

Having more fine-grained timeouts with a sensible default sounds like a great improvement (if someone wants to pick that up).

@Yoric
Copy link
Contributor

Yoric commented Feb 11, 2022

I'm currently faced with a bollard-based app that works nicely for me but timeouts on a project colleague's home computer during build (CLI docker build seems to work nicely for him). I believe that his computer is a bit slower, which may explain it.

The ability to remove or customize timeouts would indeed be very useful.

@fussybeaver
Copy link
Owner

You can configure it by calling connect_with_unix directly https://docs.rs/bollard/0.11.1/bollard/struct.Docker.html#method.connect_with_unix

I'll look into adding a method to change the timeout after instantiation, it doesn't complicated

@Yoric
Copy link
Contributor

Yoric commented Feb 11, 2022

What a coincidence :)

@lavrd
Copy link

lavrd commented Jun 9, 2022

Thank you for adding setting timeout methods! But as @sjoerdsimons said, we need different timeouts for different methods, because request for a list of containers is a fast operation but download 1gb image is not. Can we reopen this issue to add this possibility?

@fussybeaver
Copy link
Owner

How do you suggest the API should change ? It would be a bit strange to add a parameter or option to each method with a timeout argument.

Maybe with a macro?

@lavrd
Copy link

lavrd commented Jun 11, 2022

How it can be done with macro?

My thoughts was an adding method to client like with_timeout, but this method doesn't change timeout in client, just affect timeout in current method.

@fussybeaver
Copy link
Owner

Happy to re-open this for visibility.

If we can get a granular proposal for the API agreed, that might move the needle in getting it implemented.

@fussybeaver fussybeaver reopened this Jun 14, 2022
@lavrd
Copy link

lavrd commented Jun 14, 2022

I can try to make a draft pr. What do you think?

@fussybeaver
Copy link
Owner

That sounds great.

@fussybeaver fussybeaver added the help wanted Extra attention is needed label Jun 15, 2022
@lavrd
Copy link

lavrd commented Jun 16, 2022

At the moment I don't understand how to do it without Docker struct redesign

  1. as create_image method receives self by reference we can't temporary change timeout field
  2. to pass custom timeout to create_image also is not very good idea because it requires a lot of useless changes to functions which use process_request

@fussybeaver
Copy link
Owner

Thanks for giving it a shot.. I thought maybe something simpler like having a function with a callback might work, but in my naive attempt it was having issues with the borrow checker.

@lavrd
Copy link

lavrd commented Jun 4, 2023

The problem with big sized images can be solved like this:

let ci = client
        .create_image(
            Some(CreateImageOptions {
                from_image,
                ..Default::default()
            }),
            None,
            credentials,
        )
        .try_collect::<Vec<_>>();
tokio::time::timeout(Duration::from_secs(1), ci).await.unwrap().unwrap();

So, maybe timeouts per function are not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants