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

Fix retries=0 bug in PortUtils.ConnectionCheckSSH #752

Merged
merged 2 commits into from
Oct 1, 2019

Conversation

pjdarton
Copy link
Member

@pjdarton pjdarton commented Oct 1, 2019

* Issue#751 - Math.min should've been Math.max
* Removed unused imports from unit test
* Added a failure-case unit test for ConnectionCheckSSH
@@ -157,7 +157,7 @@ public ConnectionCheckSSH withSSHTimeout(int time, TimeUnit units) {
public boolean execute() throws InterruptedException {
checkState(parent.execute(), "Port %s is not opened to connect to", parent.port);

final int retries = Math.min(0, parent.retries);
final int retries = Math.max(0, parent.retries);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the bugfix.

@@ -172,16 +172,16 @@ public boolean execute() throws InterruptedException {
}

private boolean executeOnce(final int thisTryNumber, final int totalTriesIntended) {
final Connection connection = new Connection(parent.host, parent.port);
final Connection sshConnection = new Connection(parent.host, parent.port);
Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed the variable to make it clear that this was a SSH connection not merely a TCP connection that was being made.

@@ -7,18 +7,15 @@

import java.io.IOException;
import java.net.ServerSocket;
import java.util.Date;
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed some unused imports

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static java.lang.System.currentTimeMillis;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.equalTo;
Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced use of is with equalTo as "is" is deprecated.

@@ -79,19 +76,24 @@ public void shouldThrowIllegalStateExOnNotAvailPort() throws Exception {
@Test
public void shouldWaitIfPortAvailableButNotSshUntilTimeout() throws Exception {
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the buggy unit test that allowed the bug to go undetected.

@pjdarton pjdarton added the bug An issue reporting a bug or a PR fixing one. label Oct 1, 2019
@pjdarton
Copy link
Member Author

pjdarton commented Oct 1, 2019

@php50350 @biozshock This is the proposed fix for issue #751.
Please download the .hpi file from the "Last Successful Artifacts" section in https://ci.jenkins.io/job/Plugins/job/docker-plugin/job/PR-752/, install it on your Jenkins server(s) (via manage jenkins -> manage plugins -> advanced), test that it fixes the bug, and let me know the results (either here or in #751).

Once the fix is confirmed I'll merge the changes.

@biozshock
Copy link

@pjdarton the URL does not work for me:
$ telnet ci.jenkins.io 443
Trying 104.208.238.39...
telnet: Unable to connect to remote host: Connection refused

same with http

@pjdarton
Copy link
Member Author

pjdarton commented Oct 1, 2019

@biozshock That's weird. Maybe there's some internet firewall preventing you accessing that server? That server should be open to everyone on the internet...

Anyway, I've attached (a zip containing) the .hpi file here, docker-plugin-1.1.9-rc895.e262f2331080.hpi.zip. Hopefully you'll be able to download it from here.
(I had to wrap it in a zip file because github says it doesn't allow uploads of .hpi files, even though these are really zip files by another name)

@biozshock
Copy link

Seems to be working correctly here. Thanks for quick fix @pjdarton

@pjdarton pjdarton merged commit 1393598 into jenkinsci:master Oct 1, 2019
@pjdarton pjdarton deleted the bug751 branch October 1, 2019 13:57
@pjdarton
Copy link
Member Author

pjdarton commented Oct 1, 2019

OK, thanks for confirming the fix.
I've merged the code changes into master and this will be fixed in the next release.

@dschnabel
Copy link

We ran into the same issue (#751) with 1.1.8 and the 1.1.9 RC as provided above fixed it for us. Thank you.

@pjdarton
Copy link
Member Author

Code changes went into released of docker-plugin version 1.1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue reporting a bug or a PR fixing one.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants