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

Do not continue doing things after Ctrl+C #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/omnibus-ctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def scary_cleanse_warning(*args)
sleep 60
rescue Interrupt
log ""
exit 0
Kernel.exit 1
Copy link
Member Author

Choose a reason for hiding this comment

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

THese seemed a safe exit code change to make, because this is handling for when the operator explicitly does not pass the --yes argument that will bypass the wait period

Interrupted CLIs typically exit non-zero.

end
end
end
Expand Down
12 changes: 8 additions & 4 deletions spec/omnibus-ctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -676,19 +676,17 @@ def ctl_output

describe "cleanse" do
before(:each) do
# this is potentially destructive if run on a live system,
# not to mention loaded with sleeps - skip it.
# No-op everything cleanup_procs_and_nuke wants to do, it's destructive
# (and slow/sleep-laden):
allow(@ctl).to receive("cleanup_procs_and_nuke").and_return 0
end

it "should invoke the cleanse_post_hook" do
# No-op everything cleanup_procs_and_nuke wants to do, it's destructive:
expect(@ctl).to receive("command_post_hook")
@ctl.run(%w{cleanse yes})
end

it "should invoke the scary_cleanse_warning" do
# No-op everything cleanup_procs_and_nuke wants to do, it's destructive:
expect(@ctl).to receive("scary_cleanse_warning")
@ctl.run(%w{cleanse yes})
end
Expand Down Expand Up @@ -742,6 +740,12 @@ def ctl_output
@ctl.scary_cleanse_warning("cleanse")
expect(ctl_output).not_to match(/--with-external/)
end

it "will hard-stop when the operator uses Ctrl+C to exit" do
allow(@ctl).to receive(:sleep).and_raise(Interrupt)
expect(Kernel).to receive(:exit).with(1)
@ctl.scary_cleanse_warning("cleanse")
end
end

context "cleanse_post_hook" do
Expand Down