From a06cdc7d95e76b8b65eb8fce2aa2d0cad0c8b6dd Mon Sep 17 00:00:00 2001 From: nghialv Date: Mon, 12 Jul 2021 21:54:44 +0900 Subject: [PATCH] Fix bug that all plan-preview commands that come after Piped has been running for 5 minutes will be failed with deadline error --- pkg/app/piped/planpreview/handler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/app/piped/planpreview/handler.go b/pkg/app/piped/planpreview/handler.go index f2db8f55a6..b7d69bf188 100644 --- a/pkg/app/piped/planpreview/handler.go +++ b/pkg/app/piped/planpreview/handler.go @@ -164,8 +164,8 @@ func (h *Handler) Run(ctx context.Context) error { for { select { case cmd := <-cmdCh: - ctx, _ = context.WithTimeout(ctx, h.options.commandHandleTimeout) - h.handleCommand(ctx, cmd) + childCtx, _ := context.WithTimeout(ctx, h.options.commandHandleTimeout) + h.handleCommand(childCtx, cmd) case <-ctx.Done(): return @@ -284,6 +284,8 @@ func (h *Handler) handleCommand(ctx context.Context, cmd model.ReportableCommand if err := cmd.Report(ctx, model.CommandStatus_COMMAND_SUCCEEDED, nil, output); err != nil { logger.Error("failed to report command status", zap.Error(err)) + return } + logger.Info("successfully reported a success command") }