osbuild: tweak "origin=" values, thanks to Simon!

This commit is contained in:
Michael Vogt 2024-03-04 12:57:44 +01:00 committed by Ondřej Budai
parent 66468a3c58
commit 87015318d3
4 changed files with 10 additions and 10 deletions

View file

@ -337,7 +337,7 @@ class BuildRoot(contextlib.AbstractContextManager):
poller = select.poll()
poller.register(proc.stdout.fileno(), READ_ONLY)
stage_origin = "stages/" + stage_name
stage_origin = os.path.join("stages", stage_name)
while True:
buf = self.read_with_timeout(proc, poller, start, timeout)
if not buf:

View file

@ -164,7 +164,7 @@ def osbuild_cli() -> int:
if not monitor_name:
monitor_name = "NullMonitor" if args.json else "LogMonitor"
monitor = osbuild.monitor.make(monitor_name, args.monitor_fd, manifest)
monitor.log(f"starting {args.manifest_path}", origin="org.osbuild.main")
monitor.log(f"starting {args.manifest_path}", origin="osbuild.main_cli")
try:
with ObjectStore(args.store) as object_store:
@ -187,10 +187,10 @@ def osbuild_cli() -> int:
stage_timeout=stage_timeout
)
if r["success"]:
monitor.log(f"manifest {args.manifest_path} finished successfully", origin="org.osbuild.main")
monitor.log(f"manifest {args.manifest_path} finished successfully", origin="osbuild.main_cli")
else:
# if we had monitor.error() we could use that here
monitor.log(f"manifest {args.manifest_path} failed", origin="org.osbuild.main")
monitor.log(f"manifest {args.manifest_path} failed", origin="osbuild.main_cli")
if r["success"] and exports:
for pid in exports:

View file

@ -316,12 +316,12 @@ class JSONSeqMonitor(BaseMonitor):
self._context.set_pipeline(pipeline)
if pipeline.stages:
self._progress.sub_progress = Progress("stages", len(pipeline.stages))
self.log(f"Starting pipeline {pipeline.name}", origin="org.osbuild.main")
self.log(f"Starting pipeline {pipeline.name}", origin="osbuild.monitor")
# finish is for pipelines
def finish(self, results: dict):
self._progress.incr()
self.log(f"Finished pipeline {results['name']}", origin="org.osbuild.main")
self.log(f"Finished pipeline {results['name']}", origin="osbuild.monitor")
def stage(self, stage: osbuild.Stage):
self._module(stage)
@ -331,14 +331,14 @@ class JSONSeqMonitor(BaseMonitor):
def _module(self, module: osbuild.Stage):
self._context.set_stage(module)
self.log(f"Starting module {module.name}", origin="org.osbuild.main")
self.log(f"Starting module {module.name}", origin="osbuild.monitor")
# result is for modules
def result(self, result: osbuild.pipeline.BuildResult):
# we may need to check pipeline ids here in the future
if self._progress.sub_progress:
self._progress.sub_progress.incr()
self.log(f"Finished module {result.name}", origin="org.osbuild.main")
self.log(f"Finished module {result.name}", origin="osbuild.monitor")
def log(self, message, origin: Optional[str] = None):
entry = log_entry(message, self._context.with_origin(origin), self._progress)

View file

@ -246,7 +246,7 @@ def test_json_progress_monitor():
logitem = json.loads(log[i])
assert logitem["message"] == "Starting module org.osbuild.noop"
assert logitem["context"]["origin"] == "org.osbuild.main"
assert logitem["context"]["origin"] == "osbuild.monitor"
assert logitem["context"]["pipeline"]["name"] == "test-pipeline-first"
assert logitem["context"]["pipeline"]["stage"]["name"] == "org.osbuild.noop"
id_start_module = logitem["context"]["id"]
@ -277,7 +277,7 @@ def test_json_progress_monitor():
logitem = json.loads(log[i])
assert logitem["message"] == "Starting pipeline test-pipeline-second"
assert logitem["context"]["origin"] == "org.osbuild.main"
assert logitem["context"]["origin"] == "osbuild.monitor"
assert logitem["context"]["pipeline"]["name"] == "test-pipeline-second"
i += 1