From 66f159dc24e8dbde72bb09da234d8c22e4e2f4dc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 18 Oct 2024 21:04:24 +0200 Subject: [PATCH] build: log when build is cancelled I noticed that the daemon logs, even in debug, did not give any indication that the build was cancelled. This patch adds some logs to help debugging. Signed-off-by: Sebastiaan van Stijn --- api/server/router/build/build_routes.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/server/router/build/build_routes.go b/api/server/router/build/build_routes.go index 6daa4f01d2..c83dbd6fe8 100644 --- a/api/server/router/build/build_routes.go +++ b/api/server/router/build/build_routes.go @@ -245,7 +245,7 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r * } _, err = output.Write(streamformatter.FormatError(err)) if err != nil { - log.G(ctx).Warnf("could not write error response: %v", err) + log.G(ctx).WithError(err).Warn("could not write error response") } return nil } @@ -280,6 +280,9 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r * ProgressWriter: buildProgressWriter(out, wantAux, createProgressReader), }) if err != nil { + if errors.Is(err, context.Canceled) { + log.G(ctx).Debug("build canceled") + } return errf(err) }