All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2][v2] Cancel builds when cli is interrupted
@ 2016-04-29 13:10 Elliot Smith
  2016-04-29 13:10 ` [PATCH 1/2] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Elliot Smith @ 2016-04-29 13:10 UTC (permalink / raw)
  To: toaster

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] buildinfohelper: add method to set current build as CANCELLED
  2016-04-29 13:10 [PATCH 0/2][v2] Cancel builds when cli is interrupted Elliot Smith
@ 2016-04-29 13:10 ` Elliot Smith
  2016-04-29 13:10 ` [PATCH 2/2] toasterui: capture keyboard interrupts the same way as knotty Elliot Smith
  2016-05-06 10:44 ` [PATCH 0/2][v2] Cancel builds when cli is interrupted Barros Pena, Belen
  2 siblings, 0 replies; 5+ messages in thread
From: Elliot Smith @ 2016-04-29 13:10 UTC (permalink / raw)
  To: toaster

This will be used from toasterui to cancel the current command-line
build when a keyboard interrupt is captured.

[YOCTO #8515]

Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
 bitbake/lib/bb/ui/buildinfohelper.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 9397905..83dc098 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -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)
-- 
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.



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] toasterui: capture keyboard interrupts the same way as knotty
  2016-04-29 13:10 [PATCH 0/2][v2] Cancel builds when cli is interrupted Elliot Smith
  2016-04-29 13:10 ` [PATCH 1/2] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
@ 2016-04-29 13:10 ` Elliot Smith
  2016-05-06 10:44 ` [PATCH 0/2][v2] Cancel builds when cli is interrupted Barros Pena, Belen
  2 siblings, 0 replies; 5+ messages in thread
From: Elliot Smith @ 2016-04-29 13:10 UTC (permalink / raw)
  To: toaster

knotty 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]

Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
 bitbake/lib/bb/ui/toasterui.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py
index 6bf4c1f..e7c3007 100644
--- a/bitbake/lib/bb/ui/toasterui.py
+++ b/bitbake/lib/bb/ui/toasterui.py
@@ -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
-- 
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.



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2][v2] Cancel builds when cli is interrupted
  2016-04-29 13:10 [PATCH 0/2][v2] Cancel builds when cli is interrupted Elliot Smith
  2016-04-29 13:10 ` [PATCH 1/2] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
  2016-04-29 13:10 ` [PATCH 2/2] toasterui: capture keyboard interrupts the same way as knotty Elliot Smith
@ 2016-05-06 10:44 ` Barros Pena, Belen
  2016-05-06 10:48   ` Smith, Elliot
  2 siblings, 1 reply; 5+ messages in thread
From: Barros Pena, Belen @ 2016-05-06 10:44 UTC (permalink / raw)
  To: Smith, Elliot, toaster



On 29/04/2016 14:10, "toaster-bounces@yoctoproject.org on behalf of Elliot
Smith" <toaster-bounces@yoctoproject.org on behalf of
elliot.smith@intel.com> wrote:

>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/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

>
>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.
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2][v2] Cancel builds when cli is interrupted
  2016-05-06 10:44 ` [PATCH 0/2][v2] Cancel builds when cli is interrupted Barros Pena, Belen
@ 2016-05-06 10:48   ` Smith, Elliot
  0 siblings, 0 replies; 5+ messages in thread
From: Smith, Elliot @ 2016-05-06 10:48 UTC (permalink / raw)
  To: Barros Pena, Belen; +Cc: toaster

[-- Attachment #1: Type: text/plain, Size: 2052 bytes --]

On 6 May 2016 at 11:44, Barros Pena, Belen <belen.barros.pena@intel.com>
wrote:

>
>
> On 29/04/2016 14:10, "toaster-bounces@yoctoproject.org on behalf of Elliot
> Smith" <toaster-bounces@yoctoproject.org on behalf of
> elliot.smith@intel.com> wrote:
>
> >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.
>
> 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


>
> Thanks!
>
> Belén
>
> >
> >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.
> >
> >--
> >_______________________________________________
> >toaster mailing list
> >toaster@yoctoproject.org
> >https://lists.yoctoproject.org/listinfo/toaster
>
>


-- 
Elliot Smith
Software Engineer
Intel Open Source Technology Centre

[-- Attachment #2: Type: text/html, Size: 3327 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-06 10:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 13:10 [PATCH 0/2][v2] Cancel builds when cli is interrupted Elliot Smith
2016-04-29 13:10 ` [PATCH 1/2] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
2016-04-29 13:10 ` [PATCH 2/2] toasterui: capture keyboard interrupts the same way as knotty Elliot Smith
2016-05-06 10:44 ` [PATCH 0/2][v2] Cancel builds when cli is interrupted Barros Pena, Belen
2016-05-06 10:48   ` Smith, Elliot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.