Skip to content

Commit

Permalink
engine: add heartbeat interval to SSHClient
Browse files Browse the repository at this point in the history
Sometimes when host deploy/ upgrade is executed with reboot option
it fails on event 'SYSTEM_FAILED_SSH_HOST_RESTART'.
Setting a heartbeat interval on the SSHClient should keep the
connection open so that the restart will finish successfully

Change-Id: I99cbd215472b374301f5be57df6179b3f673ba97
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1917809
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1922094
Signed-off-by: Dana Elfassy <delfassy@redhat.com>
  • Loading branch information
dangel101 authored and tnisan committed Feb 4, 2021
1 parent ff5cd6f commit 1580498
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.security.KeyPair;
import java.security.MessageDigest;
import java.security.PublicKey;
import java.time.Duration;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Set;
Expand All @@ -39,6 +40,7 @@
import org.apache.sshd.common.kex.extension.DefaultClientKexExtensionHandler;
import org.apache.sshd.common.signature.BuiltinSignatures;
import org.apache.sshd.common.signature.Signature;
import org.apache.sshd.core.CoreModuleProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -52,6 +54,7 @@ public class SSHClient implements Closeable {
private static final int DEFAULT_SSH_PORT = 22;

private static final Logger log = LoggerFactory.getLogger(SSHClient.class);
private static final Duration HEARTBEAT = Duration.ofSeconds(2L);

private SshClient client;
private ClientSession session;
Expand Down Expand Up @@ -82,6 +85,7 @@ SshClient createSshClient() {
BuiltinSignatures.rsaSHA256,
BuiltinSignatures.rsa));
sshClient.setKexExtensionHandler(new DefaultClientKexExtensionHandler());
CoreModuleProperties.HEARTBEAT_INTERVAL.set(sshClient, HEARTBEAT);
return sshClient;
}

Expand Down

0 comments on commit 1580498

Please sign in to comment.