Skip to content
Permalink
Browse files

[JENKINS-51541,JENKINS-51551,...] - Remoting 3.21 + Allow passing cus…

…tom CommandTransport implementations to SlaveComputer from ComputerLauncher (#3455)

* [JENKINS-51541] - Introduce new SlaveComputer#setChannel() method which takes custom ChannelBuilder and CommandTransport

* [JENKINS-51551] - Pick Remoting version with the API patch

* [JENKINS-51541] - Listener is nullable according to the documentation

* [JENKINS-51551,JENKINS-51223,JENKINS-50965] - Update Remoting to 3.21

* [JENKINS-51541] - Restrict SlaveComputer#setChannel(ChannelBuilder cb, …) to Beta-use only
  • Loading branch information...
oleg-nenashev committed Jun 8, 2018
1 parent ec10b8c commit c405ae701c4bca18f7b4edc6e5cd3bc053b7ee60
Showing with 39 additions and 1 deletion.
  1. +38 −0 core/src/main/java/hudson/slaves/SlaveComputer.java
  2. +1 −1 pom.xml
@@ -23,6 +23,7 @@
*/
package hudson.slaves;

import com.google.common.io.NullOutputStream;
import hudson.AbortException;
import hudson.FilePath;
import hudson.Functions;
@@ -39,6 +40,7 @@
import hudson.remoting.Channel;
import hudson.remoting.ChannelBuilder;
import hudson.remoting.ChannelClosedException;
import hudson.remoting.CommandTransport;
import hudson.remoting.Launcher;
import hudson.remoting.VirtualChannel;
import hudson.security.ACL;
@@ -61,6 +63,7 @@
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.Beta;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.stapler.HttpRedirect;
import org.kohsuke.stapler.HttpResponse;
@@ -72,6 +75,7 @@
import org.kohsuke.stapler.interceptor.RequirePOST;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.OverridingMethodsMustInvokeSuper;
import javax.servlet.ServletException;
import java.io.File;
@@ -419,6 +423,40 @@ public void setChannel(InputStream in, OutputStream out, OutputStream launchLog,
setChannel(channel,launchLog,listener);
}

/**
* Creates a {@link Channel} from the given Channel Builder and Command Transport.
* This method can be used to allow {@link ComputerLauncher}s to create channels not based on I/O streams.
*
* @param cb
* Channel Builder.
* To print launch logs this channel builder should have a Header Stream defined
* (see {@link ChannelBuilder#getHeaderStream()}) in this argument or by one of {@link ChannelConfigurator}s.
* @param commandTransport
* Command Transport
* @param listener
* Gets a notification when the channel closes, to perform clean up. Can be {@code null}.
* By the time this method is called, the cause of the termination is reported to the user,
* so the implementation of the listener doesn't need to do that again.
* @since TODO
*/
@Restricted(Beta.class)
public void setChannel(@Nonnull ChannelBuilder cb,
@Nonnull CommandTransport commandTransport,
@CheckForNull Channel.Listener listener) throws IOException, InterruptedException {
for (ChannelConfigurator cc : ChannelConfigurator.all()) {
cc.onChannelBuilding(cb,this);
}

OutputStream headerStream = cb.getHeaderStream();
if (headerStream == null) {
LOGGER.log(Level.WARNING, "No header stream defined when setting channel for computer {0}. " +
"Launch log won't be printed", this);
headerStream = new NullOutputStream();
}
Channel channel = cb.build(commandTransport);
setChannel(channel, headerStream, listener);
}

/**
* Shows {@link Channel#classLoadingCount}.
* @since 1.495
@@ -106,7 +106,7 @@ THE SOFTWARE.
<maven-war-plugin.version>3.0.0</maven-war-plugin.version> <!-- JENKINS-47127 bump when 3.2.0 is out. Cf. MWAR-407 -->

<!-- Bundled Remoting version -->
<remoting.version>3.20</remoting.version>
<remoting.version>3.21</remoting.version>
<!-- Minimum Remoting version, which is tested for API compatibility -->
<remoting.minimum.supported.version>2.60</remoting.minimum.supported.version>

0 comments on commit c405ae7

Please sign in to comment.
You can’t perform that action at this time.