-
-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Conversation
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. |
|
||
verify(mockChannel).call(new ChannelPinger.SetUpRemotePing(42, 73)); | ||
verifyStatic(); | ||
ChannelPinger.setUpPingForChannel(mockChannel, 42, 73, true); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<scope>test</scope>
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, that's DependencyManagement
🐝 and 👍 |
|
||
public ChannelPinger() { | ||
pingInterval = SystemProperties.getInteger(SYS_PROPERTY_NAME, DEFAULT_PING_INTERVAL_MIN); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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
There was a problem hiding this 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); | ||
} | ||
} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 ServletContext
but I also have to take into account the deprecated property, so is not going to be so lean.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Just filed #2646 for possible future usage here and elsewhere. |
return null; | ||
} | ||
|
||
protected Object readResolve() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary?
@oleg-nenashev I've changed it to use SystemProperties care to review please? |
👎 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. |
@daniel-beck I didn't want to take authoring just unblock this, I'll take #1687 as base. |
@daniel-beck I've added #1687 commits to this PR. |
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. |
* 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)
…g interval and ping timeout in seconds
7f11459
to
a05d942
Compare
@daniel-beck, yet another try... I hope all the autoring is clear this time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐝
@reviewbybees done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🐝
@alvarolobato could you please update the Wiki page? |
@oleg-nenashev done |
This PR supersedes #1687 give that the later has been stalled for more than a year.
The objective is basically the same:
This will be updated after merge: https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties
@reviewbybees