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
This commit is contained in:
Mahmood Ali 2021-10-06 12:42:35 -04:00 committed by GitHub
parent 709c1a2947
commit 48aa6e26e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

3
.changelog/11273.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
client: Removed spurious error log messages when tasks complete
```

View File

@ -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
}