Don't report a context cancelation as an error

This commit is contained in:
Dane Everitt 2020-11-10 20:36:40 -08:00
parent 20ece60a72
commit 34349d4b48
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 7 additions and 2 deletions

View File

@ -70,7 +70,12 @@ func (e *Environment) Attach() error {
// indicates that the container is no longer running. // indicates that the container is no longer running.
go func(ctx context.Context) { go func(ctx context.Context) {
if err := e.pollResources(ctx); err != nil { if err := e.pollResources(ctx); err != nil {
log.WithField("environment_id", e.Id).WithField("error", errors.WithStackIf(err)).Error("error during environment resource polling") l := log.WithField("environment_id", e.Id)
if !errors.Is(err, context.Canceled) {
l.WithField("error", errors.WithStackIf(err)).Error("error during environment resource polling")
} else {
l.Warn("stopping server resource polling: context canceled")
}
} }
}(ctx) }(ctx)

View File

@ -35,7 +35,7 @@ func (e *Environment) pollResources(ctx context.Context) error {
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return errors.WithStackIf(ctx.Err())
default: default:
var v *types.StatsJSON var v *types.StatsJSON