bitbake: toaster: api / project Cancel any in progress builds before project delete
Before we finally delete any project make sure we send the cancel command to any in-progress builds. This ensures that an inaccessible build doesn't block up the system and that we don't get errors after deletion. [YOCTO #10289] (Bitbake rev: 263762a01a6460332ef0cfea5df1e5b81c086df4) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: bavery <brian.avery@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
8c4091a07c
commit
fffce32ebd
|
@ -49,6 +49,28 @@ class XhrBuildRequest(View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def cancel_build(br):
|
||||||
|
"""Cancel a build request"""
|
||||||
|
try:
|
||||||
|
bbctrl = bbcontroller.BitbakeController(br.environment)
|
||||||
|
bbctrl.forceShutDown()
|
||||||
|
except:
|
||||||
|
# We catch a bunch of exceptions here because
|
||||||
|
# this is where the server has not had time to start up
|
||||||
|
# and the build request or build is in transit between
|
||||||
|
# processes.
|
||||||
|
# We can safely just set the build as cancelled
|
||||||
|
# already as it never got started
|
||||||
|
build = br.build
|
||||||
|
build.outcome = Build.CANCELLED
|
||||||
|
build.save()
|
||||||
|
|
||||||
|
# We now hand over to the buildinfohelper to update the
|
||||||
|
# build state once we've finished cancelling
|
||||||
|
br.state = BuildRequest.REQ_CANCELLING
|
||||||
|
br.save()
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Build control
|
Build control
|
||||||
|
@ -74,26 +96,7 @@ class XhrBuildRequest(View):
|
||||||
for i in request.POST['buildCancel'].strip().split(" "):
|
for i in request.POST['buildCancel'].strip().split(" "):
|
||||||
try:
|
try:
|
||||||
br = BuildRequest.objects.get(project=project, pk=i)
|
br = BuildRequest.objects.get(project=project, pk=i)
|
||||||
|
self.cancel_build(br)
|
||||||
try:
|
|
||||||
bbctrl = bbcontroller.BitbakeController(br.environment)
|
|
||||||
bbctrl.forceShutDown()
|
|
||||||
except:
|
|
||||||
# We catch a bunch of exceptions here because
|
|
||||||
# this is where the server has not had time to start up
|
|
||||||
# and the build request or build is in transit between
|
|
||||||
# processes.
|
|
||||||
# We can safely just set the build as cancelled
|
|
||||||
# already as it never got started
|
|
||||||
build = br.build
|
|
||||||
build.outcome = Build.CANCELLED
|
|
||||||
build.save()
|
|
||||||
|
|
||||||
# We now hand over to the buildinfohelper to update the
|
|
||||||
# build state once we've finished cancelling
|
|
||||||
br.state = BuildRequest.REQ_CANCELLING
|
|
||||||
br.save()
|
|
||||||
|
|
||||||
except BuildRequest.DoesNotExist:
|
except BuildRequest.DoesNotExist:
|
||||||
return error_response('No such build request id %s' % i)
|
return error_response('No such build request id %s' % i)
|
||||||
|
|
||||||
|
@ -823,11 +826,21 @@ class XhrProject(View):
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
|
|
||||||
def delete(self, request, *args, **kwargs):
|
def delete(self, request, *args, **kwargs):
|
||||||
|
"""Delete a project. Cancels any builds in progress"""
|
||||||
try:
|
try:
|
||||||
Project.objects.get(pk=kwargs['project_id']).delete()
|
project = Project.objects.get(pk=kwargs['project_id'])
|
||||||
|
# Cancel any builds in progress
|
||||||
|
for br in BuildRequest.objects.filter(
|
||||||
|
project=project,
|
||||||
|
state=BuildRequest.REQ_INPROGRESS):
|
||||||
|
XhrBuildRequest.cancel_build(br)
|
||||||
|
|
||||||
|
project.delete()
|
||||||
|
|
||||||
except Project.DoesNotExist:
|
except Project.DoesNotExist:
|
||||||
return error_response("Project %s does not exist" %
|
return error_response("Project %s does not exist" %
|
||||||
kwargs['project_id'])
|
kwargs['project_id'])
|
||||||
|
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
"error": "ok",
|
"error": "ok",
|
||||||
"gotoUrl": reverse("all-projects", args=[])
|
"gotoUrl": reverse("all-projects", args=[])
|
||||||
|
|
|
@ -31,12 +31,14 @@
|
||||||
<h4>Are you sure you want to delete this project?</h4>
|
<h4>Are you sure you want to delete this project?</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Deleting the <strong class="project-name"></strong> project will remove forever:</p>
|
<p>Deleting the <strong class="project-name"></strong> project
|
||||||
|
will:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Its configuration information</li>
|
<li>Cancel its builds currently in progress</li>
|
||||||
<li>Its imported layers</li>
|
<li>Remove its configuration information</li>
|
||||||
<li>Its custom images</li>
|
<li>Remove its imported layers</li>
|
||||||
<li>All its build information</li>
|
<li>Remove its custom images</li>
|
||||||
|
<li>Remove all its build information</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
Loading…
Reference in New Issue