Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows ignoring memory modules #98

Merged
merged 3 commits into from
Sep 23, 2019
Merged

Allows ignoring memory modules #98

merged 3 commits into from
Sep 23, 2019

Conversation

mariomac
Copy link
Contributor

@mariomac mariomac commented Sep 23, 2019

Some hosts may have disabled some memory modules (e.g. memsw metrics
are not available if the Kernel is built without the
CONFIG_MEMCG_SWAP_ENABLED variable. This made the memory controller
Stat function to not work properly, because it returns error
when a single memory entry is not available.

Even if you run cgroups.Stat(cgroups.IgnoreNotExist) to ignore memory
Stat errors, you won't get most of the memory metrics.

This patch adds a configuration function parameter to the NewMemory
constructor. This way, we don't introduce breaking changes in the
current API. You can invoke the NewMemory constructor as usual or
with a new optional configuration option:

mem := cgroups.NewMemory(root, cgroups.IgnoreModules("memsw"))

If you want to let the constructor to automatically ignore memsw module
only if it is not available:

mem := cgroups.NewMemory(root, cgroups.OptionalSwap())

Signed-off-by: Mario Macias [email protected]

Mario Macias added 2 commits September 23, 2019 13:26
Some hosts may have disabled some memory modules (e.g. `memsw` metrics
are not available if the Kernel is built without the
`CONFIG_MEMCG_SWAP_ENABLED` variable. This made the memory controller
`Stat` function to not work properly, either because it returns error
when a single memory entry is not available.

Even if you run `cgroups.Stat(cgroups.IgnoreNotExist)` to ignore memory
Stat errors, you won't get most of the memory metrics.

This patch adds a configuration function parameter to the `NewMemory`
constructor. This way, we don't introduce breaking changes in the
current API. You can invoke the `NewMemory` constructor as usual or
with a new optional configuration option:

```go
mem := NewMemory(root, IgnoreModules("memsw"))
```

Signed-off-by: Mario Macias <[email protected]>
Signed-off-by: Mario Macias <[email protected]>
@codecov-io
Copy link

Codecov Report

Merging #98 into master will increase coverage by 3.24%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #98      +/-   ##
==========================================
+ Coverage   41.76%   45.01%   +3.24%     
==========================================
  Files          23       23              
  Lines        1616     1626      +10     
==========================================
+ Hits          675      732      +57     
+ Misses        817      768      -49     
- Partials      124      126       +2
Impacted Files Coverage Δ
memory.go 52.77% <100%> (+25.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf292b2...fa1a76b. Read the comment docs.

@crosbymichael
Copy link
Member

Could you make the Ignore more dynamic by checking for the memsw file as an Opt? You can keep the current IgnoreModule the same but add another opt that can be used in containerd that will add the ignore only if a stat() on memsw fails?

@mariomac
Copy link
Contributor Author

Thanks for the quick feedback @crosbymichael . I submitted a new patch with the OptionalSwap constructor option.

Feel free to suggest any other name.

@crosbymichael
Copy link
Member

LGTM

Thanks @mariomac !!

Copy link
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@estesp estesp merged commit abd0b19 into containerd:master Sep 23, 2019
thaJeztah added a commit to thaJeztah/docker that referenced this pull request Oct 31, 2019
full diff: containerd/cgroups@c4b9ac5...5fbad35

- containerd/cgroups#82 Add go module support
- containerd/cgroups#96 Move metrics proto package to stats/v1
- containerd/cgroups#97 Allow overriding the default /proc folder in blkioController
- containerd/cgroups#98 Allows ignoring memory modules
- containerd/cgroups#99 Add Go 1.13 to Travis
- containerd/cgroups#100 stats/v1: export per-cgroup stats

Signed-off-by: Sebastiaan van Stijn <[email protected]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Oct 31, 2019
full diff: containerd/cgroups@c4b9ac5...5fbad35

- containerd/cgroups#82 Add go module support
- containerd/cgroups#96 Move metrics proto package to stats/v1
- containerd/cgroups#97 Allow overriding the default /proc folder in blkioController
- containerd/cgroups#98 Allows ignoring memory modules
- containerd/cgroups#99 Add Go 1.13 to Travis
- containerd/cgroups#100 stats/v1: export per-cgroup stats

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: 27552ceb15bca544820229e574427d4c1d6ef585
Component: engine
thaJeztah added a commit to thaJeztah/docker that referenced this pull request Dec 3, 2019
full diff: containerd/cgroups@c4b9ac5...5fbad35

- containerd/cgroups#82 Add go module support
- containerd/cgroups#96 Move metrics proto package to stats/v1
- containerd/cgroups#97 Allow overriding the default /proc folder in blkioController
- containerd/cgroups#98 Allows ignoring memory modules
- containerd/cgroups#99 Add Go 1.13 to Travis
- containerd/cgroups#100 stats/v1: export per-cgroup stats

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 27552ce)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Jan 23, 2020
full diff: containerd/cgroups@c4b9ac5...5fbad35

- containerd/cgroups#82 Add go module support
- containerd/cgroups#96 Move metrics proto package to stats/v1
- containerd/cgroups#97 Allow overriding the default /proc folder in blkioController
- containerd/cgroups#98 Allows ignoring memory modules
- containerd/cgroups#99 Add Go 1.13 to Travis
- containerd/cgroups#100 stats/v1: export per-cgroup stats

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 27552ceb15bca544820229e574427d4c1d6ef585)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: 9ab162a73ac9e133a21cffbadd3339cbb5213939
Component: engine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants