Skip to content

Commit

Permalink
Ignore transient errors when gather stats
Browse files Browse the repository at this point in the history
  • Loading branch information
jsturtevant committed Jun 1, 2021
1 parent 27ffcba commit dd181c7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/kubelet/dockershim/docker_stats_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package dockershim

import (
"context"
"strings"
"time"

"github.com/Microsoft/hcsshim"
Expand All @@ -39,7 +40,7 @@ func (ds *dockerService) getContainerStats(containerID string) (*runtimeapi.Cont
// That will typically happen with init-containers in Exited state. Docker still knows about them but the HCS does not.
// As we don't want to block stats retrieval for other containers, we only log errors.
if !hcsshim.IsNotExist(err) && !hcsshim.IsAlreadyStopped(err) {
klog.Errorf("Error opening container (stats will be missing) '%s': %v", containerID, err)
klog.V(4).Infof("Error opening container (stats will be missing) '%s': %v", containerID, err)
}
return nil, nil
}
Expand All @@ -52,6 +53,16 @@ func (ds *dockerService) getContainerStats(containerID string) (*runtimeapi.Cont

stats, err := hcsshim_container.Statistics()
if err != nil {
if strings.Contains(err.Error(), "0x5") || strings.Contains(err.Error(), "0xc0370105") {
// When the container is just created, querying for stats causes access errors because it hasn't started yet
// This is transient; skip container for now
//
// These hcs errors do not have helpers exposed in public package so need to query for the known codes
// https://github.com/microsoft/hcsshim/blob/master/internal/hcs/errors.go
// PR to expose helpers in hcsshim: https://github.com/microsoft/hcsshim/pull/933
klog.V(4).Infof("Container is not in a state that stats can be accessed '%s': %v. This occurs when the container is created but not started.", containerID, err)
return nil, nil
}
return nil, err
}

Expand Down

0 comments on commit dd181c7

Please sign in to comment.