Skip to content

Switch to GNU timeout-based implementation of SSH timeouts - #679

Merged
clintoncwolfe merged 2 commits into
masterfrom
cw/fix-abandoned-sessions
Apr 22, 2021
Merged

clintoncwolfe merged 2 commits into
masterfrom
cw/fix-abandoned-sessions

Conversation

@clintoncwolfe

@clintoncwolfe clintoncwolfe commented Apr 20, 2021 •

Copy link
Copy Markdown
Contributor

Description

As the title says, this PR switches the SSH timeout feature to use the GNU timeout utility (when available) to implement command timeouts instead of using a client-side thread and closing the session, which abandons processes on the server (See #677).

This severely limits the applicability of the feature. First, the timeout utility must be installed. As it is part of gnu coreutils, it is common on Linux and other systems, but not universal, so we must do a check for it. Second, as it is a command wrapper, it does not function properly with any command string that includes pipes. Notably, all InSpec sudo commands include pipes. So, we check for pipes, and do not attempt to do a timeout on any command containing pipes.

This PR retains some functionality while making the feature safe to use. It is a compromise between letting the processes continue to run as on #677, and withdrawing the feature entirely from the SSH transport.

Related Issue

Fixes #677

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New content (non-breaking change)
  • Breaking change (a content change which would break existing functionality or processes)

Checklist:

  • I have read the CONTRIBUTING document.

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
@clintoncwolfe clintoncwolfe added Type: Bug Feature not working as expected Platform: SSH labels Apr 20, 2021
@clintoncwolfe
clintoncwolfe requested a review from a team as a code owner April 20, 2021 18:37
@clintoncwolfe
clintoncwolfe requested review from Nik08 and alexpop April 20, 2021 18:37
@clintoncwolfe
clintoncwolfe requested review from Vasu1105 and removed request for alexpop April 21, 2021 12:05
@Vasu1105

Copy link
Copy Markdown
Contributor

Thanks @clintoncwolfe this looks good to me. May be having test cases around it will be good, if possible.

Comment thread lib/train/transports/ssh_connection.rb Resolved
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
@clintoncwolfe
clintoncwolfe merged commit 1780ad6 into master Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform: SSH Type: Bug Feature not working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSH Timeout Feature Leaves Behind Processes on Target Host

3 participants