Skip to content

Commit

Permalink
Reduce cgroups read frequency to avoid kernel kernfs clock pressure
Browse files Browse the repository at this point in the history
Signed-off-by: xigang <[email protected]>
  • Loading branch information
xigang committed Dec 9, 2024
1 parent 255cff7 commit 9ba3b81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9ba3b81

Please sign in to comment.