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

Increase default SnapClient timeout to 30 seconds #111

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

neoaggelos
Copy link
Contributor

Summary

Increase default SnapClient timeout to 30 seconds

Description

SnapClient has a default timeout of 5 seconds for all RPCs to
the snapd socket. If any operation takes more, an exception is
raised to the caller.

We have seen this causing issues in slow CI environments, where
a simple config-changed hook will attempt to check if a snap is
installed, timeout and move the unit to a blocked status (causing
the CI run to fail). This is augmented by the fact that typically
SnapCache is used instead of SnapClient, which only uses the default
value and does not provide a way to configure the timeout.

Simply increasing the timeout is enough to tackle the flakes.

Notes

A possible alternative could be to surface the timeout option to SnapCache,
but that then would require each consumer of the library to set the timeout.

SnapClient has a default timeout of 5 seconds for all RPCs to
the snapd socket. If any operation takes more, an exception is
raised to the caller.

We have seen this causing issues in slow CI environments, where
a simple config-changed hook will attempt to check if a snap is
installed, timeout and move the unit to a blocked status (causing
the CI run to fail). This is augmented by the fact that typically
SnapCache is used instead of SnapClient, which only uses the default
value and does not provide a way to configure the timeout.

Simply increasing the timeout is enough to tackle the flakes.
Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Yep, this seems reasonable to me. However, we need to increment the LIBPATCH version at the top of the file. Please update that and then we can merge this.

@@ -701,7 +701,7 @@ def __init__(
opener: specifies an opener for unix socket, if unspecified a default is used
base_url: base url for making requests to the snap client. Defaults to
http://localhost/v2/
timeout: timeout in seconds to use when making requests to the API. Default is 5.0s.
timeout: timeout in seconds to use when making requests to the API. Default is 30.0s.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a pity the online lib docs don't show these defaults in the SnapClient.__init__ signature so that we have to repeat them here, but oh well.

@benhoyt benhoyt merged commit ad65cde into canonical:main Sep 14, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants