Cancel builds when cli is interrupted
v2 cover Cancel builds when cli is interrupted
If a bitbake build is running on the command line and is interrupted (e.g. by Ctrl-c), capture the interrupt and shut down the bitbake server. Also set the outcome to CANCELLED so the build displays correctly in the Toaster UI.
The following changes since commit d18d6665df5a50364d54a1524dcba34958c871a2 (poky-contrib/toaster-next):
toaster: customrecipe Only show download icon or button if it's possible (2016-04-26 17:14:46 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib elliot/toaster/8515-interrupted_cli_builds
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/toaster/8515-interrupted_cli_builds
Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8515
Elliot Smith (2):
buildinfohelper: add method to set current build as CANCELLED
toasterui: capture keyboard interrupts the same way as knotty
bitbake/lib/bb/ui/buildinfohelper.py | 10 ++++++++++ bitbake/lib/bb/ui/toasterui.py | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
--
1.9.3
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH v2 1/2 buildinfohelper: add method to set current build as CANCELLED
This will be used from toasterui to cancel the current command-line build when a keyboard interrupt is captured.
[YOCTO #8515]
--- bitbake/lib/bb/ui/buildinfohelper.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
bitbake/lib/bb/ui/buildinfohelper.py +10 -0
@@ -1251,6 +1251,16 @@ class BuildInfoHelper(object): + def cancel_cli_build(self): + """ + If a build is currently underway, set its state to CANCELLED; + note that this only gets called for command line builds which are + interrupted, so it doesn't touch any BuildRequest objects + """ + build = self.internal_state['build'] + if build: + build.outcome = Build.CANCELLED + build.save() def store_dependency_information(self, event): assert '_depgraph' in vars(event)
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH v2 2/2 toasterui: capture keyboard interrupts the same way as knotty
In reply to Elliot Smithknotty captures two levels of keyboard interrupt: a single interrupt or two interrupts in a row. These then trigger stateShutdown and stateForceShutdown respectively.
toasterui doesn't have an equivalent way of capturing interrupts and using them to shut down bitbake. Now that we are no longer using knotty + XMLRPCServer for our command line builds (since switching to per-project build directories), we see some odd side effects of this, such as builds continuing after they have been interrupted on the command line.
Bring toasterui in line with knotty (copy-paste most of the code in knotty.py which deals with interrupts) so that a keyboard interrupt actually shuts down the bitbake server (if not in observe only mode).
Additionally use the cancel_cli_build() method to set the Build status to CANCELLED in Toaster's db when we get keyboard interrupts. This means that builds interrupted on the command line show as cancelled (same as if they'd been cancelled from the Toaster UI), as specified in the UI designs.
[YOCTO #8515]
--- bitbake/lib/bb/ui/toasterui.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
bitbake/lib/bb/ui/toasterui.py +16 -1
@@ -441,7 +441,22 @@ def main(server, eventHandler, params): if ioerror.args[0] == 4: pass except KeyboardInterrupt: - main.shutdown = 1 + if params.observe_only: + print("\nKeyboard Interrupt, exiting observer...") + main.shutdown = 2 + if not params.observe_only and main.shutdown == 1: + print("\nSecond Keyboard Interrupt, stopping...\n") + _, error = server.runCommand(["stateForceShutdown"]) + if error: + logger.error("Unable to cleanly stop: %s" % error) + if not params.observe_only and main.shutdown == 0: + print("\nKeyboard Interrupt, closing down...\n") + interrupted = True + _, error = server.runCommand(["stateShutdown"]) + if error: + logger.error("Unable to cleanly shutdown: %s" % error) + buildinfohelper.cancel_cli_build() + main.shutdown = main.shutdown + 1 except Exception as e: # print errors to log import traceback
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Quoted 13 lines · On 29/04/2016 14:10, "[email protected] on behalf of Elliot…
If a bitbake build is running on the command line and is interrupted (e.g. by
Ctrl-c), capture the interrupt and shut down the bitbake server. Also set the outcome to CANCELLED so the build displays correctly in the Toaster UI.The following changes since commit
d18d6665df5a50364d54a1524dcba34958c871a2
(poky-contrib/toaster-next):toaster: customrecipe Only show download icon or button if it's
possible (2016-04-26 17:14:46 +0100)
Quoted 7 lines
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib
elliot/toaster/8515-interrupted_cli_buildshttp://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/toaster/85
15-interrupted_cli_builds
This works beautifully. The only problem is that the cancelled build shows a 'rebuild' button. When you click it, nothing happens. Since this build is part of the "Command line builds" project, no 'rebuild' button should show.
Thanks!
Belén
Quoted 30 lines
Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8515
Elliot Smith (2):
buildinfohelper: add method to set current build as CANCELLED
toasterui: capture keyboard interrupts the same way as knotty
bitbake/lib/bb/ui/buildinfohelper.py| 10 ++++++++++bitbake/lib/bb/ui/toasterui.py| 17 ++++++++++++++++-2 files changed, 26 insertions(+), 1 deletion(-)--
1.9.3---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Signature · 4 lines
_______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster
Quoted 12 lines · Belen
Quoted 5 lines · On 29/04/2016 14:10, "[email protected] on behalf of Elliot…
If a bitbake build is running on the command line and is interrupted (e.g. by
Ctrl-c), capture the interrupt and shut down the bitbake server. Also set the outcome to CANCELLED so the build displays correctly in the Toaster UI.
Quoted 5 lines
This works beautifully. The only problem is that the cancelled build shows a 'rebuild' button. When you click it, nothing happens. Since this build is part of the "Command line builds" project, no 'rebuild' button should show.
Thanks Belen, I missed that. I'll fix it.
Elliot
Quoted 37 lines
Thanks!
Belén
Quoted 30 lines
Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8515
Elliot Smith (2):
buildinfohelper: add method to set current build as CANCELLED
toasterui: capture keyboard interrupts the same way as knotty
bitbake/lib/bb/ui/buildinfohelper.py| 10 ++++++++++bitbake/lib/bb/ui/toasterui.py| 17 ++++++++++++++++-2 files changed, 26 insertions(+), 1 deletion(-)--
1.9.3---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
Signature · 3 lines
Elliot Smith Software Engineer Intel Open Source Technology Centre