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

[JENKINS-64510] Issues with TCP agent reconnects #429

Merged
merged 2 commits into from
Feb 10, 2021

Conversation

jeffret-b
Copy link
Contributor

See JENKINS-64510

The reconnect mechanism for TCP inbound agents hasn't been working properly for some period of time, most likely a long time. It's not a serious loss, but getting it working again can make some minor improvements in clarity and robustness.

This is a necessary, but insufficient, change to get it working. A corresponding change is also necessary in Jenkins core. Both are required to get it working correctly, but they're loosely coupled otherwise. Individually, they don't make the situation any worse, so it's fine to only have one of them.

Define a consistently used cookie name. Provide a way to attach the cookie to the channel.
@@ -66,7 +66,7 @@
/**
* The proprty name for the cookie name key.
*/
public static final String COOKIE_KEY = "Cookie";
public static final String COOKIE_KEY = "JnlpAgentProtocol.cookie";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use a more interesting, common name between agent and controller.

@@ -152,7 +152,7 @@ public Jnlp4ConnectionState createConnectionState(@Nonnull Socket socket,
.filter(new ConnectionHeadersFilterLayer(headers, handler))
.named(String.format("%s connection from %s", getName(), socket.getRemoteSocketAddress()))
.listener(handler)
.build(new ChannelApplicationLayer(threadPool, handler))
.build(new ChannelApplicationLayer(threadPool, handler, headers.get(JnlpConnectionState.COOKIE_KEY)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part and the corresponding additions to ChannelApplicationLayer are part of attaching the cookie to the channel properties on the controller side.

@basil
Copy link
Member

basil commented Dec 22, 2020

hudson.plugins.swarm.PipelineJobRestartTest verifies that a Swarm agent can successfully reconnect to a Jenkins controller after a restart. Would be good to confirm that this functionality in Swarm remains unaffected by this proposed change.

@jeffret-b
Copy link
Contributor Author

Yes, I certainly don't want to break that. Is that something I can easily run in a command-line or CI environment? Or otherwise, could you help test it when I have everything prepared.

@basil
Copy link
Member

basil commented Dec 22, 2020

It's a standard integration test which you can run with mvn verify or in an IDE.

@jeffret-b
Copy link
Contributor Author

Hmm ... I tried updating the Jenkins version in swarm-plugin to something recent (for example, 2.363) and it gets a compilation error in GlobalSecurityConfigurationBuilder.

@basil
Copy link
Member

basil commented Dec 22, 2020

I tried updating the Jenkins version in swarm-plugin to something recent (for example, 2.363) and it gets a compilation error in GlobalSecurityConfigurationBuilder

Presumably because jenkinsci/jenkins#4027 removed a public API from Jenkins core without updating pre-existing consumers.

CC @Wadeck

@jeffret-b
Copy link
Contributor Author

See jenkinsci/jenkins#5138 for the corresponding core changes needed to tie these together.

@jeffret-b
Copy link
Contributor Author

Maybe a rebuild will help.

@jeffret-b jeffret-b closed this Dec 22, 2020
@jeffret-b jeffret-b reopened this Dec 22, 2020
@jeffret-b
Copy link
Contributor Author

Incrementals worked this time. Currently at 4.7-rc2860.f4a9a135655d

@jeffret-b
Copy link
Contributor Author

I ran the swarm build and all the tests passed based on the updated core PR so this should be safe there.

@jeffret-b jeffret-b requested a review from jvz January 4, 2021 22:05
@jeffret-b jeffret-b added bug For changelog: Fixes a bug. ready-to-merge labels Feb 8, 2021
@jeffret-b
Copy link
Contributor Author

I'm marking this as ready-for-merge. Any further additional reviews are welcome. I'll try to merge it in a day or two.

@jeffret-b jeffret-b merged commit 2ef1eca into jenkinsci:master Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For changelog: Fixes a bug. ready-to-merge
Projects
None yet
3 participants