Skip to content

Commit 9ba3b81

Browse files
committed
Reduce cgroups read frequency to avoid kernel kernfs clock pressure
Signed-off-by: xigang <[email protected]>
1 parent 255cff7 commit 9ba3b81

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

manager/manager.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,10 @@ func (m *manager) GetContainerInfoV2(containerName string, options v2.RequestOpt
541541
}
542542

543543
func (m *manager) containerDataToContainerInfo(cont *containerData, query *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
544-
// Get the info from the container.
545-
cinfo, err := cont.GetInfo(true)
544+
// Get the info from the container. When GetInfo is set to false,
545+
// it reads cgroups once every 5 seconds and gets data from containerData cache at other times,
546+
// reducing the frequency of reading cgroups to avoid kernel kernfs clock pressure that could cause Linux machine to hang
547+
cinfo, err := cont.GetInfo(false)
546548
if err != nil {
547549
return nil, err
548550
}

manager/manager_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func createManagerAndAddContainers(
6565
spec,
6666
nil,
6767
).Once()
68+
mockHandler.On("ListContainers", container.ListSelf).Return(
69+
[]info.ContainerReference(nil),
70+
nil,
71+
).Once()
6872
cont, err := newContainerData(name, memoryCache, mockHandler, false, &collector.GenericCollectorManager{}, 60*time.Second, true, clock.NewFakeClock(time.Now()))
6973
if err != nil {
7074
t.Fatal(err)
@@ -181,10 +185,6 @@ func expectManagerWithContainers(containers []string, query *info.ContainerInfoR
181185
}
182186
spec := cinfo.Spec
183187

184-
h.On("ListContainers", container.ListSelf).Return(
185-
[]info.ContainerReference(nil),
186-
nil,
187-
)
188188
h.On("GetSpec").Return(
189189
spec,
190190
nil,

0 commit comments

Comments
 (0)