mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #90554 from vboulineau/vboulineau/fix_win_stats_init_containers
kubelet: fix `/stats/summary` endpoint on Windows when init-containers are present on the node
This commit is contained in:
commit
4339ac30a0
@ -55,8 +55,9 @@ func (ds *dockerService) ListContainerStats(ctx context.Context, r *runtimeapi.L
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stats = append(stats, containerStats)
|
||||
if containerStats != nil {
|
||||
stats = append(stats, containerStats)
|
||||
}
|
||||
}
|
||||
|
||||
return &runtimeapi.ListContainerStatsResponse{Stats: stats}, nil
|
||||
|
@ -35,7 +35,13 @@ func (ds *dockerService) getContainerStats(containerID string) (*runtimeapi.Cont
|
||||
|
||||
hcsshim_container, err := hcsshim.OpenContainer(containerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// As we moved from using Docker stats to hcsshim directly, we may query HCS with already exited container IDs.
|
||||
// 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)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
defer func() {
|
||||
closeErr := hcsshim_container.Close()
|
||||
|
@ -146,7 +146,17 @@ func newKubeletStatsTestPods(numPods int, image imageutils.Config, nodeName stri
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
InitContainers: []v1.Container{
|
||||
{
|
||||
Image: image.GetE2EImage(),
|
||||
Name: podName,
|
||||
Command: []string{
|
||||
"powershell.exe",
|
||||
"-Command",
|
||||
"sleep -Seconds 1",
|
||||
},
|
||||
},
|
||||
},
|
||||
NodeName: nodeName,
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user