summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-11-24 11:19:52 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-30 15:48:09 +0000
commit310a9e5d3564e9b07bb32e3d7b3cc94e32421968 (patch)
tree780ba1c0d7e5e937502498559e6291dc57911714
parentddaac5e4e3ebe71cb279a33a6585b3e8a8790e55 (diff)
downloadpoky-310a9e5d3564e9b07bb32e3d7b3cc94e32421968.tar.gz
bitbake: toaster: runbuilds Write the pidfile in python rather than shell script
Write the pid file out in the start up of this management command. This ensures this has happened instead of relying on the shell command having been run which may or may not be the case. This also makes it simpler for testing. Couple of clean ups of runbuilds as identified by pyflake (Bitbake rev: 999e980ee1a58d16f33ef6c0e41aecdcd0206f39) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/bin/toaster2
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py21
-rw-r--r--bitbake/lib/toaster/orm/management/commands/lsupdates.py1
3 files changed, 15 insertions, 9 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster
index f92d38ecab..e0aac1a7bb 100755
--- a/bitbake/bin/toaster
+++ b/bitbake/bin/toaster
@@ -254,7 +254,7 @@ case $CMD in
254 return 4 254 return 4
255 fi 255 fi
256 export BITBAKE_UI='toasterui' 256 export BITBAKE_UI='toasterui'
257 $MANAGE runbuilds & echo $! >${BUILDDIR}/.runbuilds.pid 257 $MANAGE runbuilds &
258 # set fail safe stop system on terminal exit 258 # set fail safe stop system on terminal exit
259 trap stop_system SIGHUP 259 trap stop_system SIGHUP
260 echo "Successful ${CMD}." 260 echo "Successful ${CMD}."
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
index 7f7a5a9555..df11f9d162 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -11,9 +11,11 @@ from orm.models import Build, LogMessage, Target
11import logging 11import logging
12import traceback 12import traceback
13import signal 13import signal
14import os
14 15
15logger = logging.getLogger("toaster") 16logger = logging.getLogger("toaster")
16 17
18
17class Command(NoArgsCommand): 19class Command(NoArgsCommand):
18 args = "" 20 args = ""
19 help = "Schedules and executes build requests as possible. "\ 21 help = "Schedules and executes build requests as possible. "\
@@ -50,7 +52,7 @@ class Command(NoArgsCommand):
50 logger.debug("runbuilds: No build env") 52 logger.debug("runbuilds: No build env")
51 return 53 return
52 54
53 logger.info("runbuilds: starting build %s, environment %s" % \ 55 logger.info("runbuilds: starting build %s, environment %s" %
54 (br, bec.be)) 56 (br, bec.be))
55 57
56 # let the build request know where it is being executed 58 # let the build request know where it is being executed
@@ -80,7 +82,7 @@ class Command(NoArgsCommand):
80 82
81 def archive(self): 83 def archive(self):
82 for br in BuildRequest.objects.filter(state=BuildRequest.REQ_ARCHIVE): 84 for br in BuildRequest.objects.filter(state=BuildRequest.REQ_ARCHIVE):
83 if br.build == None: 85 if br.build is None:
84 br.state = BuildRequest.REQ_FAILED 86 br.state = BuildRequest.REQ_FAILED
85 else: 87 else:
86 br.state = BuildRequest.REQ_COMPLETED 88 br.state = BuildRequest.REQ_COMPLETED
@@ -99,10 +101,10 @@ class Command(NoArgsCommand):
99 Q(updated__lt=timezone.now() - timedelta(seconds=30)) 101 Q(updated__lt=timezone.now() - timedelta(seconds=30))
100 ).update(lock=BuildEnvironment.LOCK_FREE) 102 ).update(lock=BuildEnvironment.LOCK_FREE)
101 103
102
103 # update all Builds that were in progress and failed to start 104 # update all Builds that were in progress and failed to start
104 for br in BuildRequest.objects.filter(state=BuildRequest.REQ_FAILED, 105 for br in BuildRequest.objects.filter(
105 build__outcome=Build.IN_PROGRESS): 106 state=BuildRequest.REQ_FAILED,
107 build__outcome=Build.IN_PROGRESS):
106 # transpose the launch errors in ToasterExceptions 108 # transpose the launch errors in ToasterExceptions
107 br.build.outcome = Build.FAILED 109 br.build.outcome = Build.FAILED
108 for brerror in br.brerror_set.all(): 110 for brerror in br.brerror_set.all():
@@ -117,7 +119,6 @@ class Command(NoArgsCommand):
117 br.environment.lock = BuildEnvironment.LOCK_FREE 119 br.environment.lock = BuildEnvironment.LOCK_FREE
118 br.environment.save() 120 br.environment.save()
119 121
120
121 # update all BuildRequests without a build created 122 # update all BuildRequests without a build created
122 for br in BuildRequest.objects.filter(build=None): 123 for br in BuildRequest.objects.filter(build=None):
123 br.build = Build.objects.create(project=br.project, 124 br.build = Build.objects.create(project=br.project,
@@ -144,7 +145,7 @@ class Command(NoArgsCommand):
144 145
145 # Make sure the LOCK is removed for builds which have been fully 146 # Make sure the LOCK is removed for builds which have been fully
146 # cancelled 147 # cancelled
147 for br in BuildRequest.objects.filter(\ 148 for br in BuildRequest.objects.filter(
148 Q(build__outcome=Build.CANCELLED) & 149 Q(build__outcome=Build.CANCELLED) &
149 Q(state=BuildRequest.REQ_CANCELLING) & 150 Q(state=BuildRequest.REQ_CANCELLING) &
150 ~Q(environment=None)): 151 ~Q(environment=None)):
@@ -168,6 +169,12 @@ class Command(NoArgsCommand):
168 logger.warn("runbuilds: schedule exception %s" % str(e)) 169 logger.warn("runbuilds: schedule exception %s" % str(e))
169 170
170 def handle_noargs(self, **options): 171 def handle_noargs(self, **options):
172 pidfile_path = os.path.join(os.environ.get("BUILDDIR", "."),
173 ".runbuilds.pid")
174
175 with open(pidfile_path, 'w') as pidfile:
176 pidfile.write("%s" % os.getpid())
177
171 self.runbuild() 178 self.runbuild()
172 179
173 signal.signal(signal.SIGUSR1, lambda sig, frame: None) 180 signal.signal(signal.SIGUSR1, lambda sig, frame: None)
diff --git a/bitbake/lib/toaster/orm/management/commands/lsupdates.py b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
index 688918e68c..68c6c423d8 100644
--- a/bitbake/lib/toaster/orm/management/commands/lsupdates.py
+++ b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
@@ -90,7 +90,6 @@ class Command(NoArgsCommand):
90 from urlparse import urlparse 90 from urlparse import urlparse
91 91
92 proxy_settings = os.environ.get("http_proxy", None) 92 proxy_settings = os.environ.get("http_proxy", None)
93 oe_core_layer = 'openembedded-core'
94 93
95 def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER): 94 def _get_json_response(apiurl=DEFAULT_LAYERINDEX_SERVER):
96 http_progress = Spinner() 95 http_progress = Spinner()