toaster.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
From: Marlon Rodriguez Garcia <marlon.rodriguez-garcia@savoirfairelinux.com>
To: bitbake-devel@lists.openembedded.org, toaster@lists.yoctoproject.org
Cc: Marlon Rodriguez Garcia <marlon.rodriguez-garcia@savoirfairelinux.com>
Subject: [PATCH] toaster: Added validation to stop import if there is a build in progress
Date: Thu, 14 Dec 2023 14:44:09 -0500	[thread overview]
Message-ID: <20231214194409.16525-1-marlon.rodriguez-garcia@savoirfairelinux.com> (raw)

Added validation to prevent simultaneous imports from running because the database fails at runtime.
The option to create a queue was taken into consideration. However, it will require the use of Celery https://pypi.org/project/celery/ or Background Task https://pypi.org/project/django-background-tasks/ which require the use of external services and multiple dependencies.
If required we could explore the alternative in the future.

Signed-off-by: Marlon Rodriguez Garcia <marlon.rodriguez-garcia@savoirfairelinux.com>
---
 lib/toaster/toastergui/templates/command_line_builds.html | 6 +++++-
 lib/toaster/toastergui/views.py                           | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/toaster/toastergui/templates/command_line_builds.html b/lib/toaster/toastergui/templates/command_line_builds.html
index fcbe80d8..05db6727 100644
--- a/lib/toaster/toastergui/templates/command_line_builds.html
+++ b/lib/toaster/toastergui/templates/command_line_builds.html
@@ -152,7 +152,11 @@ function _ajax_update(file, all, dir){
         type: "POST",
         data: {file: file, all: all, dir: dir},
         success:function(data){
-            window.location = '/toastergui/builds/'
+            if (data['response']=='building'){
+                location.reload()
+            } else {
+                window.location = '/toastergui/builds/'
+            }
         },
         complete:function(data){
         },
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 3b5b9f5b..40aed265 100644
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -2018,6 +2018,14 @@ class CommandLineBuilds(TemplateView):
         logs_dir = request.POST.get('dir')
         all_files =  request.POST.get('all')
 
+        # check if a build is already in progress
+        if Build.objects.filter(outcome=Build.IN_PROGRESS):
+            messages.add_message(
+                self.request,
+                messages.ERROR,
+                "A build is already in progress. Please wait for it to complete before starting a new build."
+            )
+            return JsonResponse({'response': 'building'})
         imported_files = EventLogsImports.objects.all()
         try:
             if all_files == 'true':
-- 
2.34.1



                 reply	other threads:[~2023-12-14 19:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231214194409.16525-1-marlon.rodriguez-garcia@savoirfairelinux.com \
    --to=marlon.rodriguez-garcia@savoirfairelinux.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=toaster@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).