From f219f7d1ead90abede190cd74a3c5c4cdc580457 Mon Sep 17 00:00:00 2001 From: calvin0327 Date: Sun, 11 Dec 2022 21:44:14 +0800 Subject: [PATCH] fix sdNotify func when debug level Signed-off-by: wen chen --- cmd/containerd/command/notify_linux.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/containerd/command/notify_linux.go b/cmd/containerd/command/notify_linux.go index f97a1d3a5..bf0026030 100644 --- a/cmd/containerd/command/notify_linux.go +++ b/cmd/containerd/command/notify_linux.go @@ -36,10 +36,13 @@ func notifyStopping(ctx context.Context) error { func sdNotify(ctx context.Context, state string) error { notified, err := sd.SdNotify(false, state) - log.G(ctx). - WithError(err). - WithField("notified", notified). + entry := log.G(ctx) + if err != nil { + entry = entry.WithError(err) + } + entry.WithField("notified", notified). WithField("state", state). Debug("sd notification") + return err }