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

squash SSH failure when skippable true and exception message matches expected #1579

Merged
merged 11 commits into from
Jun 2, 2021

Conversation

tarcinil
Copy link
Contributor

@tarcinil tarcinil commented Jul 27, 2019

This will still run the command and output the failure, but when Kitchen::Transport:Ssh::Connection#execute has an error code that isn't zero, it causes the issue seen in #1543.

This will allow lifecycle_hooks to squash the expception if skipable is true and the message matches what we expect from the raise in the transport. It will just re-raise the original exception otherwise.

fixes #1543

@tarcinil
Copy link
Contributor Author

tarcinil commented Sep 1, 2019

@tas50 - I have fixed the merge conflict as well as a future issue with the lacking of 2.6.2 ruby in Pipelines which will affect all future testing.

@tarcinil tarcinil closed this May 12, 2020
@tarcinil tarcinil reopened this May 12, 2020
@marcparadise
Copy link
Contributor

Could you bring this back up to date @tarcinil , so we can get it merged in?

@tarcinil
Copy link
Contributor Author

tarcinil commented Jun 2, 2021

@marcparadise I have updated my PR. I didn't create any tests because of the nature of the change, but it can be tested via CLI.

In the master, when you perform a kitchen converge, it will converge an empty runlist. Once you execute kitchen destroy, it should land into the pre_destroy that raises the following failure.

$ be kitchen destroy default-ubuntu-1604 
-----> Starting Test Kitchen (v2.11.2)
       sudo: adleave: command not found
#<Thread:0x00007f910326f980@/Users/vburton/.rvm/gems/ruby-2.6.5/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:471 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        13: from /Users/vburton/.rvm/gems/ruby-2.6.5/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
        12: from /Users/vburton/Code/test-kitchen/lib/kitchen/command.rb:166:in `block (2 levels) in run_action'
        11: from /Users/vburton/Code/test-kitchen/lib/kitchen/command.rb:195:in `run_action_in_thread'
        10: from /Users/vburton/Code/test-kitchen/lib/kitchen/command.rb:195:in `public_send'
         9: from /Users/vburton/Code/test-kitchen/lib/kitchen/instance.rb:172:in `destroy'
         8: from /Users/vburton/Code/test-kitchen/lib/kitchen/instance.rb:390:in `transition_to'
         7: from /Users/vburton/Code/test-kitchen/lib/kitchen/instance.rb:390:in `each'
         6: from /Users/vburton/Code/test-kitchen/lib/kitchen/instance.rb:391:in `block in transition_to'
         5: from /Users/vburton/Code/test-kitchen/lib/kitchen/lifecycle_hooks.rb:46:in `run_with_hooks'
         4: from /Users/vburton/Code/test-kitchen/lib/kitchen/lifecycle_hooks.rb:68:in `run'
         3: from /Users/vburton/Code/test-kitchen/lib/kitchen/lifecycle_hooks.rb:68:in `each'
         2: from /Users/vburton/Code/test-kitchen/lib/kitchen/lifecycle_hooks.rb:73:in `block in run'
         1: from /Users/vburton/Code/test-kitchen/lib/kitchen/lifecycle_hook/remote.rb:22:in `run'
/Users/vburton/Code/test-kitchen/lib/kitchen/transport/ssh.rb:142:in `execute': SSH exited (1) for command: [sudo adleave] (Kitchen::Transport::SshFailed)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::Transport::SshFailed
>>>>>> Message: SSH exited (1) for command: [sudo adleave]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

If you perform the same steps against my changes, it is handled cleanly when skippable is true. It will fail to the above error if skippable is not added to the remote command.

$ be kitchen destroy default-ubuntu-1604
-----> Starting Test Kitchen (v2.11.2)
       sudo: adleave: command not found
-----> Destroying <default-ubuntu-1604>...
       ==> default: Forcing shutdown of VM...
       ==> default: Destroying VM and associated drives...
       Vagrant instance <default-ubuntu-1604> destroyed.
       Finished destroying <default-ubuntu-1604> (0m4.19s).
-----> Test Kitchen is finished. (0m7.69s)

@marcparadise marcparadise merged commit 536d30a into test-kitchen:master Jun 2, 2021
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.

lifecyle hooks skippable true not honored when defined in platforms
4 participants