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 JENKINS-28245] - Allow defining agent ping interval and ping timeout in seconds #2645

Merged
merged 2 commits into from
Dec 14, 2016

Conversation

alvarolobato
Copy link
Member

This PR supersedes #1687 give that the later has been stalled for more than a year.

The objective is basically the same:

  • Define ping interval in seconds and be able to customize it with a system property
  • Define timeout in seconds and be able to customize it with a system property

This will be updated after merge: https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties
@reviewbybees

@ghost
Copy link

ghost commented Nov 24, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@alvarolobato alvarolobato changed the title [JENKINS-28245] - Allow defining agent ping interval and ping timeout in seconds [FIX JENKINS-28245] - Allow defining agent ping interval and ping timeout in seconds Nov 24, 2016

verify(mockChannel).call(new ChannelPinger.SetUpRemotePing(42, 73));
verifyStatic();
ChannelPinger.setUpPingForChannel(mockChannel, 42, 73, true);
Copy link
Member

Choose a reason for hiding this comment

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

Are this calls at the end of all test methods testing something specific?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes,

verifyStatic();
ChannelPinger.setUpPingForChannel(mockChannel, 42, 73, true);

verifies that the method ChannelPinger.setUpPingForChannel(mockChannel, 42, 73, true); is called with those parameter in that order.

I know, really odd syntax.

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<version>${guavaVersion}</version>
Copy link
Member

Choose a reason for hiding this comment

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

<scope>test</scope>?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I see it's the child module.

Copy link
Member Author

Choose a reason for hiding this comment

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

right, that's DependencyManagement

@amuniz
Copy link
Member

amuniz commented Nov 24, 2016

🐝 and 👍


public ChannelPinger() {
pingInterval = SystemProperties.getInteger(SYS_PROPERTY_NAME, DEFAULT_PING_INTERVAL_MIN);
Copy link
Member

Choose a reason for hiding this comment

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

🐛 Why do you get rid of SystemProperties

Copy link
Member Author

Choose a reason for hiding this comment

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

It was a mistake, changing it.

Copy link
Member

Choose a reason for hiding this comment

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

fixed

private int pingInterval;
public SetUpRemotePing(int pingInterval) {
this.pingInterval = pingInterval;
private transient int pingInterval;
Copy link
Member

Choose a reason for hiding this comment

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

Should be deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

This is a callable, why not just remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

To be compatible in cases were we have the old version of the class on the other side. I had it removed at first but then decided to go the safe way. Are we sure that this situation cannot happen?, I so, I will remove it.

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

🐛 for not using SystemProperties. If there is a point in it, it needs to be justified

Copy link
Member

@batmat batmat left a comment

Choose a reason for hiding this comment

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

🐝 though I think the code at the beginning could be made leaner

} catch (NumberFormatException e) {
LOGGER.warning("Ignoring invalid " + SYS_PROPERTY_NAME_TIMEOUT_SECONDS + "=" + timeout);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this code should use SystemProperties#getInteger() isn't it?

And if you want to log warnings, then maybe we just want to create a third overloaded method to specify the desired Level?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I'm going to fix that, it really needs to use SystemProperties instead of System.getProperty to be able to get the properties from the ServletContextbut I also have to take into account the deprecated property, so is not going to be so lean.

Copy link
Member

Choose a reason for hiding this comment

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

Are we sure that all code paths that lead to evaluating the system property are assured to be on the master's JVM... if not, then you actually had this correct... if on master only, there's a marker interface you are missing

Copy link
Member Author

Choose a reason for hiding this comment

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

@stephenc yes this is always on the master, the only part used on the agents is SetUpRemotePing callable. Which marker interface? Isn't it better to just use SystemProperties

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Use SystemProperties when you know the value will only ever be queried from the master

@batmat
Copy link
Member

batmat commented Nov 24, 2016

Just filed #2646 for possible future usage here and elsewhere.

return null;
}

protected Object readResolve() {
Copy link
Member

Choose a reason for hiding this comment

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

Is this really necessary?

@alvarolobato
Copy link
Member Author

@oleg-nenashev I've changed it to use SystemProperties care to review please?

@daniel-beck
Copy link
Member

👎 This appears to copy nontrivial amounts of code from #1687 without any attribution. If you're reusing parts of that PR (such as the practically identical tests), you should have e.g. the first commit be just (parts of) the other PR with @deadmoose as commit author.

@oleg-nenashev oleg-nenashev added the needs-comments-resolved Comments in the PR need to be addressed before it can be considered for merging label Nov 27, 2016
@alvarolobato
Copy link
Member Author

alvarolobato commented Nov 28, 2016

@daniel-beck I didn't want to take authoring just unblock this, I'll take #1687 as base.

@alvarolobato
Copy link
Member Author

@daniel-beck I've added #1687 commits to this PR.

@alvarolobato alvarolobato reopened this Nov 28, 2016
@batmat batmat removed the needs-comments-resolved Comments in the PR need to be addressed before it can be considered for merging label Nov 28, 2016
@daniel-beck
Copy link
Member

This should just be rebased onto @deadmoose's commit, or a commit declaring deadmoose as author that includes the parts you're incorporating into your PR. There's still commits with questionable authorship in this PR's history.

deadmoose and others added 2 commits November 29, 2016 10:28
 * Allows customization in seconds, not minutes
 * Allows customization of the ping timeout (before, you could set a
   custom interval, but the timeout would always be PingThread's 4
   minute default)

This also drops the serialVersionUID from ChannelPinger.SetUpRemotePing;
without one provided, the JVM will generate one on demand which is
sufficient for the purposes here since these are never persisted and
master & slave run the same compiled code. (And it demonstrably works
since countless other MasterToSlaveCallables fail to specify their own
custom IDs)
@alvarolobato
Copy link
Member Author

@daniel-beck, yet another try... I hope all the autoring is clear this time

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

LGTM 🐝

@daniel-beck daniel-beck added the needs-more-reviews Complex change, which would benefit from more eyes label Nov 30, 2016
@alvarolobato
Copy link
Member Author

@reviewbybees done

Copy link
Member

@batmat batmat left a comment

Choose a reason for hiding this comment

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

👍 🐝

@oleg-nenashev oleg-nenashev merged commit 1868c84 into jenkinsci:master Dec 14, 2016
@oleg-nenashev
Copy link
Member

@alvarolobato could you please update the Wiki page?

@alvarolobato
Copy link
Member Author

@oleg-nenashev done

@oleg-nenashev oleg-nenashev removed the needs-more-reviews Complex change, which would benefit from more eyes label Dec 15, 2016
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.

7 participants