Skip to content

Commit

Permalink
osbuild: tweak "origin=" values, thanks to Simon!
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 authored and ondrejbudai committed Mar 12, 2024
1 parent 66468a3 commit 8701531
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion osbuild/buildroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def run(self, argv, monitor, timeout=None, binds=None, readonly_binds=None, extr
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:
Expand Down
6 changes: 3 additions & 3 deletions osbuild/main_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions osbuild/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ def begin(self, pipeline: osbuild.Pipeline):
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)
Expand All @@ -331,14 +331,14 @@ def assembler(self, assembler: osbuild.Stage):

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)
Expand Down
4 changes: 2 additions & 2 deletions test/mod/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 8701531

Please sign in to comment.