From 14834e6085e5227d1baface0aa057cccb34ffc29 Mon Sep 17 00:00:00 2001 From: Kohei Tokunaga Date: Wed, 18 Oct 2023 12:28:14 +0900 Subject: [PATCH] debug: print error message on monitor instead of processes pkg This can catch and print more errors on monitor side not only process-related errors. Signed-off-by: Kohei Tokunaga --- controller/processes/processes.go | 6 +----- monitor/monitor.go | 6 +++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controller/processes/processes.go b/controller/processes/processes.go index c8738601..3cd9e14f 100644 --- a/controller/processes/processes.go +++ b/controller/processes/processes.go @@ -137,11 +137,7 @@ func (m *Manager) StartProcess(pid string, resultCtx *build.ResultHandle, cfg *p go func() { var err error if err = ctr.Exec(ctx, cfg, in.Stdin, in.Stdout, in.Stderr); err != nil { - if errors.Is(err, context.Canceled) { - logrus.Debugf("process canceled: %v", err) - } else { - logrus.Errorf("failed to exec process: %v", err) - } + logrus.Debugf("process error: %v", err) } logrus.Debugf("finished process %s %v", pid, cfg.Entrypoint) m.processes.Delete(pid) diff --git a/monitor/monitor.go b/monitor/monitor.go index 559c2222..1201e79a 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -302,7 +302,11 @@ func (m *monitor) startInvoke(ctx context.Context, pid string, cfg controllerapi go func() { // Start a new invoke if err := m.invoke(ctx, pid, cfg); err != nil { - logrus.Debugf("invoke error: %v", err) + if errors.Is(err, context.Canceled) { + logrus.Debugf("process canceled: %v", err) + } else { + logrus.Errorf("invoke: %v", err) + } } if pid == m.attachedPid.Load() { m.attachedPid.Store("")