From 48aa6e26e938e1c54c226d6c7304b8bef3fcdc64 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Wed, 6 Oct 2021 12:42:35 -0400 Subject: [PATCH] executor: suppress spurious log messages (#11273) Suppress stats streaming error log messages when task finishes. Streaming errors are expected when a task finishes and they aren't actionable to users. Also, note that the task runner Stats hook retries collecting stats after a delay. If the connection terminates prematurely, it will be retried, and closing the stats stream is not very disruptive. Ideally, executor terminates cleanly when task exits, but that's a more substantial change that may require changing the executor/drivers interface. Fixes #10814 --- .changelog/11273.txt | 3 +++ drivers/shared/executor/client.go | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 .changelog/11273.txt diff --git a/.changelog/11273.txt b/.changelog/11273.txt new file mode 100644 index 000000000..3bada6f66 --- /dev/null +++ b/.changelog/11273.txt @@ -0,0 +1,3 @@ +```release-note:bug +client: Removed spurious error log messages when tasks complete +``` diff --git a/drivers/shared/executor/client.go b/drivers/shared/executor/client.go index 1779d919a..44f459e91 100644 --- a/drivers/shared/executor/client.go +++ b/drivers/shared/executor/client.go @@ -16,6 +16,8 @@ import ( "github.com/hashicorp/nomad/helper/pluginutils/grpcutils" "github.com/hashicorp/nomad/plugins/drivers" dproto "github.com/hashicorp/nomad/plugins/drivers/proto" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) var _ Executor = (*grpcExecutorClient)(nil) @@ -132,12 +134,14 @@ func (c *grpcExecutorClient) handleStats(ctx context.Context, stream proto.Execu return } - if err != nil { - if err != io.EOF { - c.logger.Error("error receiving stream from Stats executor RPC, closing stream", "error", err) - } - - // End stream + if err == io.EOF || + status.Code(err) == codes.Unavailable || + status.Code(err) == codes.Canceled || + err == context.Canceled { + c.logger.Trace("executor Stats stream closed", "msg", err) + return + } else if err != nil { + c.logger.Warn("failed to receive Stats executor RPC stream, closing stream", "error", err) return }