summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2015-09-11 13:57:29 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-18 09:05:33 +0100
commitb6d1d2acd58c949f7b8879fe5087c8846ac51a54 (patch)
tree1b60bb3b8b605532fcf4eadf7f3a6b0ae11d9346
parent8c63d6049d221da0c5211f847ddf13e0e45dd459 (diff)
downloadpoky-b6d1d2acd58c949f7b8879fe5087c8846ac51a54.tar.gz
bitbake: toaster: Avoid unnecessary local to local copy of cooker log
The cooker log is copied from its original (bitbake) location to an artifact directory chosen by the user (chosen when checksettings.py runs as part of the managed mode; it's one of the annoying questions you're asked at startup). The copy happens as part of the runbuilds script run, which is started in a loop from the toaster startup script in managed mode. When a user requests the log for a build via toaster, they are getting the log which has been copied to the artifact directory, not the original bitbake log. This works for the managed case, where the runbuilds command is running in a loop and copying log files for completed builds to the artifact directory. However, in analysis mode, there are two problems: 1. checksettings isn't run, so the artifacts directory isn't set. toaster is then unable to figure out where the log files should have been copied to. 2. The log files aren't copied to the artifacts directory anyway, as runbuilds isn't running in analysis mode. To fix this, just point the user to the local bitbake log file in its original location. This avoids the copy step, and means we can remove a whole question from the toaster startup sequence, as we no longer need an artifact directory. The only downside to this is that it's not appropriate for remote bitbake servers. We will need to revisit this and possibly reinstate the copy step once we have to reconcile local and remote builds and make their logs available in the same way. [YOCTO #8209] (Bitbake rev: 5697bbcc88edad85891f66d28b8803a9c9d27ff2) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py22
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py24
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py13
3 files changed, 8 insertions, 51 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
index 3ccc7c67c9..b2c573c9eb 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
@@ -64,27 +64,6 @@ class Command(NoArgsCommand):
64 return "" 64 return ""
65 return DN(self._find_first_path_for_file(DN(self.guesspath), "bblayers.conf", 4)) 65 return DN(self._find_first_path_for_file(DN(self.guesspath), "bblayers.conf", 4))
66 66
67
68 def _verify_artifact_storage_dir(self):
69 # verify that we have a settings for downloading artifacts
70 while ToasterSetting.objects.filter(name="ARTIFACTS_STORAGE_DIR").count() == 0:
71 guessedpath = os.getcwd() + "/toaster_build_artifacts/"
72 print("\nToaster needs to know in which directory it can download build log files and other artifacts.\nToaster suggests \"%s\"." % guessedpath)
73 artifacts_storage_dir = raw_input("Press Enter to select \"%s\" or type the full path to a different directory: " % guessedpath)
74 if len(artifacts_storage_dir) == 0:
75 artifacts_storage_dir = guessedpath
76 if len(artifacts_storage_dir) > 0 and artifacts_storage_dir.startswith("/"):
77 try:
78 os.makedirs(artifacts_storage_dir)
79 except OSError as ose:
80 if "File exists" in str(ose):
81 pass
82 else:
83 raise ose
84 ToasterSetting.objects.create(name="ARTIFACTS_STORAGE_DIR", value=artifacts_storage_dir)
85 return 0
86
87
88 def _verify_build_environment(self): 67 def _verify_build_environment(self):
89 # refuse to start if we have no build environments 68 # refuse to start if we have no build environments
90 while BuildEnvironment.objects.count() == 0: 69 while BuildEnvironment.objects.count() == 0:
@@ -239,7 +218,6 @@ class Command(NoArgsCommand):
239 218
240 def handle_noargs(self, **options): 219 def handle_noargs(self, **options):
241 retval = 0 220 retval = 0
242 retval += self._verify_artifact_storage_dir()
243 retval += self._verify_build_environment() 221 retval += self._verify_build_environment()
244 retval += self._verify_default_settings() 222 retval += self._verify_default_settings()
245 retval += self._verify_builds_in_progress() 223 retval += self._verify_builds_in_progress()
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
index c3e9b74c09..718e1441dc 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -77,31 +77,11 @@ class Command(NoArgsCommand):
77 bec.be.save() 77 bec.be.save()
78 78
79 def archive(self): 79 def archive(self):
80 ''' archives data from the builds '''
81 artifact_storage_dir = ToasterSetting.objects.get(name="ARTIFACTS_STORAGE_DIR").value
82 for br in BuildRequest.objects.filter(state = BuildRequest.REQ_ARCHIVE): 80 for br in BuildRequest.objects.filter(state = BuildRequest.REQ_ARCHIVE):
83 # save cooker log
84 if br.build == None: 81 if br.build == None:
85 br.state = BuildRequest.REQ_FAILED 82 br.state = BuildRequest.REQ_FAILED
86 br.save() 83 else:
87 continue 84 br.state = BuildRequest.REQ_COMPLETED
88 build_artifact_storage_dir = os.path.join(artifact_storage_dir, "%d" % br.build.pk)
89 try:
90 os.makedirs(build_artifact_storage_dir)
91 except OSError as ose:
92 if "File exists" in str(ose):
93 pass
94 else:
95 raise ose
96
97 file_name = os.path.join(build_artifact_storage_dir, "cooker_log.txt")
98 try:
99 with open(file_name, "w") as f:
100 f.write(br.environment.get_artifact(br.build.cooker_log_path).read())
101 except IOError:
102 os.unlink(file_name)
103
104 br.state = BuildRequest.REQ_COMPLETED
105 br.save() 85 br.save()
106 86
107 def cleanup(self): 87 def cleanup(self):
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 4e8f69e801..784272fd70 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2710,7 +2710,6 @@ if True:
2710 2710
2711 def build_artifact(request, build_id, artifact_type, artifact_id): 2711 def build_artifact(request, build_id, artifact_type, artifact_id):
2712 if artifact_type in ["cookerlog"]: 2712 if artifact_type in ["cookerlog"]:
2713 # these artifacts are saved after building, so they are on the server itself
2714 def _mimetype_for_artifact(path): 2713 def _mimetype_for_artifact(path):
2715 try: 2714 try:
2716 import magic 2715 import magic
@@ -2741,16 +2740,16 @@ if True:
2741 except ImportError: 2740 except ImportError:
2742 return "binary/octet-stream" 2741 return "binary/octet-stream"
2743 try: 2742 try:
2744 # match code with runbuilds.Command.archive() 2743 build = Build.objects.get(pk = build_id)
2745 build_artifact_storage_dir = os.path.join(ToasterSetting.objects.get(name="ARTIFACTS_STORAGE_DIR").value, "%d" % int(build_id)) 2744 file_name = build.cooker_log_path
2746 file_name = os.path.join(build_artifact_storage_dir, "cooker_log.txt")
2747
2748 fsock = open(file_name, "r") 2745 fsock = open(file_name, "r")
2749 content_type=_mimetype_for_artifact(file_name) 2746 content_type = _mimetype_for_artifact(file_name)
2750 2747
2751 response = HttpResponse(fsock, content_type = content_type) 2748 response = HttpResponse(fsock, content_type = content_type)
2752 2749
2753 response['Content-Disposition'] = 'attachment; filename=' + os.path.basename(file_name) 2750 disposition = 'attachment; filename=cooker.log'
2751 response['Content-Disposition'] = disposition
2752
2754 return response 2753 return response
2755 except IOError: 2754 except IOError:
2756 context = { 2755 context = {