SshDaemon: introduce sshd.waitTimeout to set WAIT_FOR_SPACE_TIMEOUT

sshd introduced a new channel property
'channel-output-wait-for-space-timeout' [1] set by default to 30s.

The property isn't exposed at the ChannelSessionFactory level and thus
the default value remained hardcoded in the properties.

Without this config the consequence is that clones that requires the
server process to spend over 30s are failing.

Allow administrators to configure this via a new setting sshd.waitTimout.

Default to 30 seconds if it is not set.

[1] https://issues.apache.org/jira/browse/SSHD-565

Bug: Issue 7425
Change-Id: Ib3fd9a25d7eaaa87a15d5c159995e09a9581dadb
This commit is contained in:
Paladox none 2017-10-14 16:18:42 +00:00
parent 1c9076053e
commit daafdb6512
2 changed files with 19 additions and 0 deletions

View File

@ -3732,6 +3732,20 @@ should use common unit suffixes to express their setting:
+
By default, 0.
[[sshd.waitTimeout]]sshd.waitTimeout::
+
Time in seconds after which the server automatically terminates idle connections
connections (e.g. cloning a very large repo with lots of refs)
Values should use common unit suffixes to express their setting:
+
* s, sec, second, seconds
* m, min, minute, minutes
* h, hr, hour, hours
* d, day, days
+
By default, 30s.
[[sshd.maxConnectionsPerUser]]sshd.maxConnectionsPerUser::
+
Maximum number of concurrent SSH sessions that a user account

View File

@ -17,6 +17,7 @@ package com.google.gerrit.sshd;
import static com.google.gerrit.server.ssh.SshAddressesModule.IANA_SSH_PORT;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.sshd.common.channel.ChannelOutputStream.WAIT_FOR_SPACE_TIMEOUT;
import com.google.common.base.Strings;
import com.google.common.base.Supplier;
@ -194,6 +195,10 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
getProperties().put(REKEY_BYTES_LIMIT,
String.valueOf(cfg.getLong("sshd", "rekeyBytesLimit", 1024 * 1024 * 1024 /* 1GB */)));
long waitTimeoutSeconds = ConfigUtil.getTimeUnit(cfg, "sshd", null, "waitTimeout", 30, SECONDS);
getProperties()
.put(WAIT_FOR_SPACE_TIMEOUT, String.valueOf(SECONDS.toMillis(waitTimeoutSeconds)));
final int maxConnectionsPerUser =
cfg.getInt("sshd", "maxConnectionsPerUser", 64);
if (0 < maxConnectionsPerUser) {