Tech-debt: don't use signal handlers to handle ctrl-c

Bug #1586476 reported by Joshua Harlow
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kolla
Fix Released
Medium
Joshua Harlow

Bug Description

When running in a multi-threaded program (which the kolla build command is) it is bad practice to try to forcefully (and typically incorrectly) shutdown by doing things like 'sys.exit' to exit the main program when those threads are active. Instead the ctrl-c interrupt should be handled gracefully and the threads should be requested to stop, and then they should be waited until they are stopped and then (and only then) should the main program actually stop.

This isn't rocket science, and is well documented all over the web (such as in http://stackoverflow.com/a/11436603 )

Joshua Harlow (harlowja)
Changed in kolla:
assignee: nobody → Joshua Harlow (harlowja)
Changed in kolla:
status: New → In Progress
Steven Dake (sdake)
Changed in kolla:
importance: Undecided → Medium
milestone: none → newton-1
Revision history for this message
Jeff Peeler (jpeeler-z) wrote :

I figured since most of the processing work was being given to docker, it didn't matter if the threads were terminated violently. Do you disagree with that?

Revision history for this message
Jeff Peeler (jpeeler-z) wrote :

I see the review here https://review.openstack.org/#/c/321913/, so clearly you do disagree. It's already approved, so I won't block it. But it doesn't look like it'll interrupt as quickly, which was the functionality I was attempting to preserve.

Revision history for this message
Joshua Harlow (harlowja) wrote :

I don't like threads terminating violently out of principle. So ya, I disagree with that, if u want to interrupt it more quickly, then further break apart the workflow that is the build workflow into smaller segments that can individually be stopped. Unless the code has been designed with crash-tolerance in mind (most code doesn't seem to be, outside a database or similar kind of system) then it seems better to try to interrupt in a nice happy manner.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on kolla (master)

Change abandoned by Joshua Harlow (<email address hidden>) on branch: master
Review: https://review.openstack.org/321909

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla (master)

Reviewed: https://review.openstack.org/321913
Committed: https://git.openstack.org/cgit/openstack/kolla/commit/?id=869e117b536b685e45cee161948c78d6241c5df3
Submitter: Jenkins
Branch: master

commit 869e117b536b685e45cee161948c78d6241c5df3
Author: Joshua Harlow <email address hidden>
Date: Wed Jun 8 17:10:08 2016 -0700

    Add non-intrusive ctrl-c handling

    Instead of trying to use a signal handler to stop
    when ctrl-c is triggered use technique that cooperates
    better with the threads that are running and lets
    them die a happy death vs being forced to die in
    unpleasant ways.

    Closes-Bug: #1586476

    Change-Id: I7fdb6a77a144bdd02276cca07b616bbb0c2f1957

Changed in kolla:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/kolla 3.0.0.0b2

This issue was fixed in the openstack/kolla 3.0.0.0b2 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.