All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] [v3] Cancel builds when cli is interrupted
@ 2016-05-06 11:53 Elliot Smith
  2016-05-06 11:53 ` [PATCH 1/3] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Elliot Smith @ 2016-05-06 11:53 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 c8ea873d9883f8cdabb6ccadd31bd9967a0f0111:

  toaster: tweaks to recipe file downloads (2016-04-29 14:21:32 +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 (3):
  buildinfohelper: add method to set current build as CANCELLED
  toasterui: capture keyboard interrupts the same way as knotty
  toaster: don't show "Rebuild" button for cancelled cli builds

 bitbake/lib/bb/ui/buildinfohelper.py               | 10 +++++++++
 bitbake/lib/bb/ui/toasterui.py                     | 17 ++++++++++++++-
 .../toaster/toastergui/templates/mrb_section.html  | 25 ++++++++++++----------
 3 files changed, 40 insertions(+), 12 deletions(-)

--
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] 6+ messages in thread

* [PATCH 1/3] buildinfohelper: add method to set current build as CANCELLED
  2016-05-06 11:53 [PATCH 0/3] [v3] Cancel builds when cli is interrupted Elliot Smith
@ 2016-05-06 11:53 ` Elliot Smith
  2016-05-06 11:53 ` [PATCH 2/3] toasterui: capture keyboard interrupts the same way as knotty Elliot Smith
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Elliot Smith @ 2016-05-06 11:53 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] 6+ messages in thread

* [PATCH 2/3] toasterui: capture keyboard interrupts the same way as knotty
  2016-05-06 11:53 [PATCH 0/3] [v3] Cancel builds when cli is interrupted Elliot Smith
  2016-05-06 11:53 ` [PATCH 1/3] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
@ 2016-05-06 11:53 ` Elliot Smith
  2016-05-06 11:53 ` [PATCH 3/3] toaster: don't show "Rebuild" button for cancelled cli builds Elliot Smith
  2016-05-06 14:24 ` [PATCH 0/3] [v3] Cancel builds when cli is interrupted Barros Pena, Belen
  3 siblings, 0 replies; 6+ messages in thread
From: Elliot Smith @ 2016-05-06 11:53 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] 6+ messages in thread

* [PATCH 3/3] toaster: don't show "Rebuild" button for cancelled cli builds
  2016-05-06 11:53 [PATCH 0/3] [v3] Cancel builds when cli is interrupted Elliot Smith
  2016-05-06 11:53 ` [PATCH 1/3] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
  2016-05-06 11:53 ` [PATCH 2/3] toasterui: capture keyboard interrupts the same way as knotty Elliot Smith
@ 2016-05-06 11:53 ` Elliot Smith
  2016-05-06 14:24 ` [PATCH 0/3] [v3] Cancel builds when cli is interrupted Barros Pena, Belen
  3 siblings, 0 replies; 6+ messages in thread
From: Elliot Smith @ 2016-05-06 11:53 UTC (permalink / raw)
  To: toaster

[YOCTO #8515]

Signed-off-by: Elliot Smith <elliot.smith@intel.com>
---
 .../toaster/toastergui/templates/mrb_section.html  | 25 ++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
index b5e798d..212998a 100644
--- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html
+++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
@@ -125,8 +125,6 @@
                       pull-right"
                       data-request-url="{% url 'xhr_buildrequest' build.project.pk %}"
                       data-target='{{build.target_set.all|get_tasks|json}}'>
-
-
                         Rebuild
                   </button>
               {% endif %}
@@ -144,7 +142,7 @@
     <div class="lead span3 progress-info"><span id="build-pc-done-{{build.pk}}">{{build.completeper}}</span>% of tasks complete</div>
     {# No build cancel for command line builds project #}
     {% if build.project.is_default %}
-    <i class="icon-question-sign get-help get-help-blue pull-right" title="" data-original-title="Builds in this project cannot be cancelled from Toaster: they can only be cancalled from the command line"></i>
+    <i class="icon-question-sign get-help get-help-blue pull-right" title="" data-original-title="Builds in this project cannot be cancelled from Toaster: they can only be cancelled from the command line"></i>
     {% else %}
     <div class="lead pull-right progress-info">
       <button class="cancel-build-btn btn btn-info pull-right"
@@ -158,15 +156,20 @@
     {%endif%} {# end if in progress #}
 
     {% if build.outcome == build.CANCELLED %}
-    <div class="span4">
-      <p class="lead">Build cancelled</p>
-    </div>
-    <button class="btn btn-info pull-right run-again-btn"
-        data-request-url="{% url 'xhr_buildrequest' build.project.pk %}"
-        data-target='{{build.target_set.all|get_tasks|json}}'>
-      Rebuild
+      <div class="span4">
+        <p class="lead">Build cancelled</p>
+      </div>
 
-    </button>
+      {% if build.project.is_default %}
+        <i class="icon-question-sign get-help get-help-blue pull-right" title=""
+          data-original-title="Builds in this project cannot be rebuilt from Toaster: they can only be rebuilt from the command line"></i>
+      {% else %}
+        <button class="btn btn-info pull-right run-again-btn"
+                data-request-url="{% url 'xhr_buildrequest' build.project.pk %}"
+                data-target='{{build.target_set.all|get_tasks|json}}'>
+          Rebuild
+        </button>
+      {% endif %}
     {% endif %}
   </div>
 </div>
-- 
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] 6+ messages in thread

* Re: [PATCH 0/3] [v3] Cancel builds when cli is interrupted
  2016-05-06 11:53 [PATCH 0/3] [v3] Cancel builds when cli is interrupted Elliot Smith
                   ` (2 preceding siblings ...)
  2016-05-06 11:53 ` [PATCH 3/3] toaster: don't show "Rebuild" button for cancelled cli builds Elliot Smith
@ 2016-05-06 14:24 ` Barros Pena, Belen
  2016-05-12 14:11   ` Michael Wood
  3 siblings, 1 reply; 6+ messages in thread
From: Barros Pena, Belen @ 2016-05-06 14:24 UTC (permalink / raw)
  To: Smith, Elliot, toaster@yoctoproject.org



On 06/05/2016 12:53, "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
>c8ea873d9883f8cdabb6ccadd31bd9967a0f0111:
>
>  toaster: tweaks to recipe file downloads (2016-04-29 14:21:32 +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 for me. Thanks!

Belén

>
>Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8515
>
>Elliot Smith (3):
>  buildinfohelper: add method to set current build as CANCELLED
>  toasterui: capture keyboard interrupts the same way as knotty
>  toaster: don't show "Rebuild" button for cancelled cli builds
>
> bitbake/lib/bb/ui/buildinfohelper.py               | 10 +++++++++
> bitbake/lib/bb/ui/toasterui.py                     | 17 ++++++++++++++-
> .../toaster/toastergui/templates/mrb_section.html  | 25
>++++++++++++----------
> 3 files changed, 40 insertions(+), 12 deletions(-)
>
>--
>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] 6+ messages in thread

* Re: [PATCH 0/3] [v3] Cancel builds when cli is interrupted
  2016-05-06 14:24 ` [PATCH 0/3] [v3] Cancel builds when cli is interrupted Barros Pena, Belen
@ 2016-05-12 14:11   ` Michael Wood
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Wood @ 2016-05-12 14:11 UTC (permalink / raw)
  To: toaster

Sent upstream and push to toaster-next

Thanks,

Michael

On 06/05/16 15:24, Barros Pena, Belen wrote:
>
> On 06/05/2016 12:53, "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
>> c8ea873d9883f8cdabb6ccadd31bd9967a0f0111:
>>
>>   toaster: tweaks to recipe file downloads (2016-04-29 14:21:32 +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 for me. Thanks!
>
> Belén
>
>> Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8515
>>
>> Elliot Smith (3):
>>   buildinfohelper: add method to set current build as CANCELLED
>>   toasterui: capture keyboard interrupts the same way as knotty
>>   toaster: don't show "Rebuild" button for cancelled cli builds
>>
>> bitbake/lib/bb/ui/buildinfohelper.py               | 10 +++++++++
>> bitbake/lib/bb/ui/toasterui.py                     | 17 ++++++++++++++-
>> .../toaster/toastergui/templates/mrb_section.html  | 25
>> ++++++++++++----------
>> 3 files changed, 40 insertions(+), 12 deletions(-)
>>
>> --
>> 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] 6+ messages in thread

end of thread, other threads:[~2016-05-12 14:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-06 11:53 [PATCH 0/3] [v3] Cancel builds when cli is interrupted Elliot Smith
2016-05-06 11:53 ` [PATCH 1/3] buildinfohelper: add method to set current build as CANCELLED Elliot Smith
2016-05-06 11:53 ` [PATCH 2/3] toasterui: capture keyboard interrupts the same way as knotty Elliot Smith
2016-05-06 11:53 ` [PATCH 3/3] toaster: don't show "Rebuild" button for cancelled cli builds Elliot Smith
2016-05-06 14:24 ` [PATCH 0/3] [v3] Cancel builds when cli is interrupted Barros Pena, Belen
2016-05-12 14:11   ` Michael Wood

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.