Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request #4715: configurable ssh connect timeout #4914

Merged
merged 32 commits into from
Jul 20, 2020
Merged

Feature request #4715: configurable ssh connect timeout #4914

merged 32 commits into from
Jul 20, 2020

Conversation

winem
Copy link
Contributor

@winem winem commented Apr 18, 2020

This PR adds support for ssh_connect_timeout as new configuration parameter in the ssh_runner group. It was suggested in #4715 and follows the fail-fast principle when the SSH connection can not even be established.

The runner will fail if the TCP connect to the target host does not succeed within the specified timeout. (see: http://docs.paramiko.org/en/stable/api/client.html -> SSHClient -> connect -> timeout).

This was tested with a high number of test cases with different defaults, ssh_connect_timeouts in the st2.conf and a variation of action timeouts.

This one makes #4913 which I just closed obsolete.

@pull-request-size pull-request-size bot added the size/M PR that changes 30-99 lines. Good size to review. label Apr 18, 2020
@arm4b arm4b added this to the 3.3.0 milestone Apr 19, 2020
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

This change is helpful, thanks for working on that!

To follow-up, check the CI build failure, - it shows some real suggestions around adding this new st2.conf setting.

CHANGELOG.rst Outdated Show resolved Hide resolved
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

Are there any unit tests we can add for this new PR enhancement?

@winem
Copy link
Contributor Author

winem commented Jun 3, 2020

I thought about the unit tests as well and back then I just knew how to test it manually. It's probably a bit tricky but I think I just got an idea for a proper unit test that can differentiate between failures due to breaching the timeout and the ssh_connect_timeout. I'll work on it over the weekend.

@winem
Copy link
Contributor Author

winem commented Jun 8, 2020

Marked as draft because a merge of the master branch into my feature branch went wrong. Will provide the proper solution before end of this week.

In the meantime any input regarding my previous comment and the unit tests is highly appreciated!

@winem
Copy link
Contributor Author

winem commented Jun 20, 2020

Are there any unit tests we can add for this new PR enhancement?

Hi @armab, first of all, I fixed all the lint issues so that the current tests pass.

I thought about the tests a bit more and am not sure what a proper implementation would look like. I know that some people use google.com:81 in tests to run a timeout but I think that every request to foreign infrastructure should be avoided (and is just the wrong way).

Only thing that seems to be an option is to use Mocks side_effects and raise an exception. In this case we would see the exception but it's just a mocked one and does not actually prove that the action failed after the ssh_connect_timeout which would have to be lower than the action timeout in this case.

So I ran out of ideas but am all in for ideas and every input is appreciated. Please let me know if you have any ideas or any hints for something I could look into.

Cheers,
Marcel

CHANGELOG.rst Outdated Show resolved Hide resolved
CHANGELOG.rst Outdated Show resolved Hide resolved
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thanks for the contribution!

@winem
Copy link
Contributor Author

winem commented Jul 19, 2020

Anytime! What do you think about the (missing) tests? Do you see any chance to cover this feature by a test?

@arm4b
Copy link
Member

arm4b commented Jul 20, 2020

Currently I can't help much here, but I really appreciate the effort trying to add the test scenarios. If nothing worked, - I'm good to merge it as is.

@arm4b arm4b merged commit a0acb2f into StackStorm:master Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature size/M PR that changes 30-99 lines. Good size to review. status:needs tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants