From 15804980bbb7e6c0de529e72f2d1fc2b5e9716d7 Mon Sep 17 00:00:00 2001 From: Dana Elfassy Date: Sun, 31 Jan 2021 18:12:45 +0200 Subject: [PATCH] engine: add heartbeat interval to SSHClient 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 --- .../main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java index 35b3aa87439..74f7ca39708 100644 --- a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java +++ b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java @@ -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; @@ -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; @@ -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; @@ -82,6 +85,7 @@ SshClient createSshClient() { BuiltinSignatures.rsaSHA256, BuiltinSignatures.rsa)); sshClient.setKexExtensionHandler(new DefaultClientKexExtensionHandler()); + CoreModuleProperties.HEARTBEAT_INTERVAL.set(sshClient, HEARTBEAT); return sshClient; }