summaryrefslogtreecommitdiffstats
path: root/bitbake
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:10:30 +0100
commit55b6fabd75a66a4d3b3ee07525cd5a4dc33ca98e (patch)
treedeb99a1da327f567788d02883ff86731897f5fa3 /bitbake
parentf4cee8840e51658a0002bf339ff49b7409dc8544 (diff)
downloadpoky-55b6fabd75a66a4d3b3ee07525cd5a4dc33ca98e.tar.gz
bitbake: 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. (Bitbake rev: 23d0a7f9664450a09c2610631b38590a09b33744) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
index 8ba836ee4b..4c1c6a7428 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -1,5 +1,7 @@
1from django.core.management.base import NoArgsCommand, CommandError 1from django.core.management.base import NoArgsCommand, CommandError
2from django.db import transaction 2from django.db import transaction
3from django.db.models import Q
4
3from orm.models import Build, ToasterSetting, LogMessage, Target 5from orm.models import Build, ToasterSetting, LogMessage, Target
4from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException 6from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException
5from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable 7from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable
@@ -86,13 +88,20 @@ class Command(NoArgsCommand):
86 def cleanup(self): 88 def cleanup(self):
87 from django.utils import timezone 89 from django.utils import timezone
88 from datetime import timedelta 90 from datetime import timedelta
89 # environments locked for more than 30 seconds - they should be unlocked
90 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)
91
92
93 # update all Builds that failed to start 91 # update all Builds that failed to start
94 92
95 for br in BuildRequest.objects.filter(state = BuildRequest.REQ_FAILED, build__outcome = Build.IN_PROGRESS): 93 for br in BuildRequest.objects.filter(state = BuildRequest.REQ_FAILED, build__outcome = Build.IN_PROGRESS):
94 # environments locked for more than 30 seconds
95 # they should be unlocked
96 BuildEnvironment.objects.filter(
97 Q(buildrequest__state__in=[BuildRequest.REQ_FAILED,
98 BuildRequest.REQ_COMPLETED,
99 BuildRequest.REQ_CANCELLING]) &
100 Q(lock=BuildEnvironment.LOCK_LOCK) &
101 Q(updated__lt=timezone.now() - timedelta(seconds = 30))
102 ).update(lock=BuildEnvironment.LOCK_FREE)
103
104
96 # transpose the launch errors in ToasterExceptions 105 # transpose the launch errors in ToasterExceptions
97 br.build.outcome = Build.FAILED 106 br.build.outcome = Build.FAILED
98 for brerror in br.brerror_set.all(): 107 for brerror in br.brerror_set.all():
@@ -125,6 +134,15 @@ class Command(NoArgsCommand):
125 br.build.save() 134 br.build.save()
126 pass 135 pass
127 136
137 # Make sure the LOCK is removed for builds which have been fully
138 # cancelled
139 for br in BuildRequest.objects.filter(
140 Q(build__outcome=Build.CANCELLED) &
141 Q(state=BuildRequest.REQ_CANCELLING) &
142 ~Q(environment=None)):
143 br.environment.lock = BuildEnvironment.LOCK_FREE
144 br.environment.save()
145
128 146
129 def handle_noargs(self, **options): 147 def handle_noargs(self, **options):
130 while True: 148 while True: