diff options
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py | 26 |
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 @@ | |||
1 | from django.core.management.base import NoArgsCommand, CommandError | 1 | from django.core.management.base import NoArgsCommand, CommandError |
2 | from django.db import transaction | 2 | from django.db import transaction |
3 | from django.db.models import Q | ||
4 | |||
3 | from orm.models import Build, ToasterSetting, LogMessage, Target | 5 | from orm.models import Build, ToasterSetting, LogMessage, Target |
4 | from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException | 6 | from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException |
5 | from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable | 7 | from 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: |