mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Add tracing to GetContainerStats
This commit is contained in:
parent
2cfc85c8b3
commit
cd8d8f2dce
@ -77,6 +77,7 @@ type FakeDockerClient struct {
|
|||||||
execCmd []string
|
execCmd []string
|
||||||
EnableSleep bool
|
EnableSleep bool
|
||||||
ImageHistoryMap map[string][]dockerimagetypes.HistoryResponseItem
|
ImageHistoryMap map[string][]dockerimagetypes.HistoryResponseItem
|
||||||
|
ContainerStatsMap map[string]*dockertypes.StatsJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -913,9 +914,19 @@ func (f *FakeDockerPuller) GetImageRef(image string) (string, error) {
|
|||||||
return image, err
|
return image, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FakeDockerClient) InjectContainerStats(data map[string]*dockertypes.StatsJSON) {
|
||||||
|
f.Lock()
|
||||||
|
defer f.Unlock()
|
||||||
|
f.ContainerStatsMap = data
|
||||||
|
}
|
||||||
|
|
||||||
func (f *FakeDockerClient) GetContainerStats(id string) (*dockertypes.StatsJSON, error) {
|
func (f *FakeDockerClient) GetContainerStats(id string) (*dockertypes.StatsJSON, error) {
|
||||||
f.Lock()
|
f.Lock()
|
||||||
defer f.Unlock()
|
defer f.Unlock()
|
||||||
f.appendCalled(CalledDetail{name: "getContainerStats"})
|
f.appendCalled(CalledDetail{name: "get_container_stats"})
|
||||||
return nil, fmt.Errorf("not implemented")
|
stats, ok := f.ContainerStatsMap[id]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("container %q not found", id)
|
||||||
|
}
|
||||||
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user