Skip to content

Warn when launch timeout is set below the recommended minimum - #1000

Open
om7057 wants to merge 2 commits into
jenkinsci:mainfrom
om7057:fix/warn-below-recommended-launch-timeout-899
Open

Warn when launch timeout is set below the recommended minimum#1000
om7057 wants to merge 2 commits into
jenkinsci:mainfrom
om7057:fix/warn-below-recommended-launch-timeout-899

Conversation

@om7057

@om7057 om7057 commented Aug 9, 2026

Copy link
Copy Markdown

Fixes #899

SSHConnector.doCheckLaunchTimeoutSeconds only rejected negative or non-numeric values. A small but positive value, for example 1 second, passed validation silently even though it is known to make agent connections flaky, since it does not leave enough time for the SSH handshake and the remoting handshake to complete.

This adds a warning, not an error, when the value is positive but below the plugin's own default of 60 seconds (SSHLauncher.DEFAULT_LAUNCH_TIMEOUT_SECONDS). The behavior of existing configurations that intentionally use a low timeout is not changed, and the value itself is not modified, only a warning is shown on the configuration page.

I deliberately did not enforce a hard floor by clamping the value, since SSHLauncherTest.timeoutAndRetrySettings already asserts that an explicit value like 39 seconds is honored exactly, and other tests confirm only non-positive values fall back to the default. Silently overriding a user-supplied value below 60 would have broken that existing, intentional behavior.

The check lives in SSHConnector rather than SSHLauncher. SSHLauncher's own config.jelly only renders the host field directly and delegates rendering of every other field, including launchTimeoutSeconds, to SSHConnector's config.jelly and descriptor via <st:include page="config.jelly" class="${descriptor.sshConnectorClass}"/>. So this single check in SSHConnector.DescriptorImpl already covers both the SSHConnector-based cloud connector UI and the SSHLauncher-based permanent agent UI.

Testing done

Added SSHConnectorTest with 7 cases covering: below minimum (warning), at minimum (ok), above minimum (ok), blank (ok), negative (error), not a number (error), and zero (ok, since zero is handled separately by falling back to the default elsewhere and should not also warn here).

Ran the full existing test suite locally on JDK 25 (matching this repo's linux CI leg): all passing, including SSHLauncherTest.timeoutAndRetrySettings which confirms this change does not alter the existing timeout value behavior. Also verified ./mvnw spotless:check passes clean.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

SSHConnector.doCheckLaunchTimeoutSeconds only rejected negative or
non-numeric values. A small but positive value, for example 1 second,
passed validation silently even though it is known to make agent
connections flaky, since it does not leave enough time for the SSH
handshake and remoting handshake to complete.

This adds a warning, not an error, when the value is positive but
below the plugin's own default of 60 seconds, so the behavior of
existing configurations with an intentionally low timeout is not
changed. The value itself is not modified.

The check lives in SSHConnector rather than SSHLauncher because
SSHLauncher's own config.jelly delegates rendering of this field
to SSHConnector's config.jelly and descriptor, so this single check
already covers both the SSHConnector and SSHLauncher configuration
UIs.

Fixes jenkinsci#899
@om7057
om7057 requested a review from a team as a code owner August 9, 2026 18:35
Copilot AI lite review requested due to automatic review settings August 9, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves configuration-time validation for SSH agent launch timeouts by warning (rather than failing) when users enter a positive timeout below the plugin’s recommended minimum (the default 60s), addressing flakiness reported in #899 while preserving existing runtime behavior.

Changes:

  • Add a FormValidation.Kind.WARNING when launchTimeoutSeconds is positive but below DEFAULT_LAUNCH_TIMEOUT_SECONDS.
  • Add a localized warning message for the new validation outcome.
  • Add a focused regression test suite covering warning/ok/error cases for the launch timeout field.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/hudson/plugins/sshslaves/SSHConnector.java Adds a warning for low positive launch timeout values during descriptor form validation.
src/main/resources/hudson/plugins/sshslaves/Messages.properties Adds the new i18n message used for the low-timeout warning.
src/test/java/hudson/plugins/sshslaves/SSHConnectorTest.java Adds regression tests covering the new warning behavior and existing error/ok cases.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main/java/hudson/plugins/sshslaves/SSHConnector.java Outdated
Makes the Stapler binding for this parameter explicit rather than
relying on retained debug parameter names, matching the other
doCheck methods in this file. Suggested by review.
@om7057

om7057 commented Aug 9, 2026

Copy link
Copy Markdown
Author

Applied in 5497fa2, thanks for the catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-55858] validate connection timeout values are not fewer than 60 seconds

2 participants