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

Enhancement: (re-)Add "Read Timeout" to DockerCloud. #610

Merged
merged 1 commit into from
Jan 24, 2018

Conversation

pjdarton
Copy link
Member

It's possible for a docker API endpoint to seize up, accepting incoming connections but never replying. This causes docker-plugin's calls to the docker API to hang, causing Jenkins' call to the docker-plugin to hang, causing Jenkins' cloud functionality to hang, crippling Jenkins.
To handle this, the docker-plugin must timeout so that it won't wait forever for the docker-api to return, and treat a timeout as a failure. This will help mitigate #594.
This code change re-introduces the functionality as follows:

  • Re-add readTimeout to the docker cloud configuration
  • Re-add readTimeout to the docker API
  • Enhance docker-java code to support readTimeout.
  • Improve help text for both connectTimeout and readTimeout.

Note: This functionality was present in older versions of the plugin but was lost due to later versions of the docker-java library missing this functionality. There's a separate issue to put that back again. Once the official docker-java release is enhanced to support readTimeout, this plugin can remove its own enhanced NettyDockerCmdFactory and go back to using the docker-java version directly.

It's possible for a docker API endpoint to seize up, accepting incoming
connections but never replying.  To cope with this situation, we need
the docker-plugin to timeout and fail instead of just hanging.
client = DockerClientBuilder.getInstance(
new DefaultDockerClientConfig.Builder()
.withDockerHost(dockerHost.getUri())
.withCustomSslConfig(toSSlConfig(dockerHost.getCredentialsId()))
)
.withDockerCmdExecFactory(new NettyDockerCmdExecFactory()
.withConnectTimeout(connectTimeout))
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I'm pretty sure that this old code was buggy - withConnectTimeout expects to be given milliseconds (or null for "no timeout"), but connectTimeout is in seconds.

final Version v = vc.exec();
final String actualVersion = v.getVersion();
final String actualApiVersion = v.getApiVersion();
return FormValidation.ok("Version = " + actualVersion + ", API Version = " + actualApiVersion);
Copy link
Member Author

Choose a reason for hiding this comment

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

Splitting the test code up so that we only get one method call per line means that, in the event of a failure, the exception trace will tell us exactly where the problem came from.
e.g. If everything is on one line and we get a NullPointerException then it's impossible to see which bit failed.

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