diff --git a/manager/manager.go b/manager/manager.go index 8043394d5d..4a3dffc20c 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -541,8 +541,10 @@ func (m *manager) GetContainerInfoV2(containerName string, options v2.RequestOpt } func (m *manager) containerDataToContainerInfo(cont *containerData, query *info.ContainerInfoRequest) (*info.ContainerInfo, error) { - // Get the info from the container. - cinfo, err := cont.GetInfo(true) + // Get the info from the container. When GetInfo is set to false, + // it reads cgroups once every 5 seconds and gets data from containerData cache at other times, + // reducing the frequency of reading cgroups to avoid kernel kernfs clock pressure that could cause Linux machine to hang + cinfo, err := cont.GetInfo(false) if err != nil { return nil, err } diff --git a/manager/manager_test.go b/manager/manager_test.go index 6e6312a69f..7da9c1318f 100644 --- a/manager/manager_test.go +++ b/manager/manager_test.go @@ -65,6 +65,10 @@ func createManagerAndAddContainers( spec, nil, ).Once() + mockHandler.On("ListContainers", container.ListSelf).Return( + []info.ContainerReference(nil), + nil, + ).Once() cont, err := newContainerData(name, memoryCache, mockHandler, false, &collector.GenericCollectorManager{}, 60*time.Second, true, clock.NewFakeClock(time.Now())) if err != nil { t.Fatal(err) @@ -181,10 +185,6 @@ func expectManagerWithContainers(containers []string, query *info.ContainerInfoR } spec := cinfo.Spec - h.On("ListContainers", container.ListSelf).Return( - []info.ContainerReference(nil), - nil, - ) h.On("GetSpec").Return( spec, nil,