summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-04-06 17:46:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-06 23:00:10 +0100
commit23d0a7f9664450a09c2610631b38590a09b33744 (patch)
tree85161de81e9754da0a70bdd108622ff39e2935b4
parentc3c29fd4eb5116b771e8e16281d4e3cdf4fae165 (diff)
downloadopenembedded-core-contrib-23d0a7f9664450a09c2610631b38590a09b33744.tar.gz
toaster: runbuilds Make runbuilds aware of the build CANCELLED state
Add handlers to make sure we remove the BuildEnvironment LOCK when we have cancelled a build. Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/toaster/bldcontrol/management/commands/runbuilds.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/toaster/bldcontrol/management/commands/runbuilds.py b/lib/toaster/bldcontrol/management/commands/runbuilds.py
index 8ba836ee4b..4c1c6a7428 100644
--- a/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -1,5 +1,7 @@
from django.core.management.base import NoArgsCommand, CommandError
from django.db import transaction
+from django.db.models import Q
+
from orm.models import Build, ToasterSetting, LogMessage, Target
from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException
from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable
@@ -86,13 +88,20 @@ class Command(NoArgsCommand):
def cleanup(self):
from django.utils import timezone
from datetime import timedelta
- # environments locked for more than 30 seconds - they should be unlocked
- BuildEnvironment.objects.filter(buildrequest__state__in=[BuildRequest.REQ_FAILED, BuildRequest.REQ_COMPLETED]).filter(lock=BuildEnvironment.LOCK_LOCK).filter(updated__lt = timezone.now() - timedelta(seconds = 30)).update(lock = BuildEnvironment.LOCK_FREE)
-
-
# update all Builds that failed to start
for br in BuildRequest.objects.filter(state = BuildRequest.REQ_FAILED, build__outcome = Build.IN_PROGRESS):
+ # environments locked for more than 30 seconds
+ # they should be unlocked
+ BuildEnvironment.objects.filter(
+ Q(buildrequest__state__in=[BuildRequest.REQ_FAILED,
+ BuildRequest.REQ_COMPLETED,
+ BuildRequest.REQ_CANCELLING]) &
+ Q(lock=BuildEnvironment.LOCK_LOCK) &
+ Q(updated__lt=timezone.now() - timedelta(seconds = 30))
+ ).update(lock=BuildEnvironment.LOCK_FREE)
+
+
# transpose the launch errors in ToasterExceptions
br.build.outcome = Build.FAILED
for brerror in br.brerror_set.all():
@@ -125,6 +134,15 @@ class Command(NoArgsCommand):
br.build.save()
pass
+ # Make sure the LOCK is removed for builds which have been fully
+ # cancelled
+ for br in BuildRequest.objects.filter(
+ Q(build__outcome=Build.CANCELLED) &
+ Q(state=BuildRequest.REQ_CANCELLING) &
+ ~Q(environment=None)):
+ br.environment.lock = BuildEnvironment.LOCK_FREE
+ br.environment.save()
+
def handle_noargs(self, **options):
while True: