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

Add oom_score_adj to set default oom score adj #1367

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/containers.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ Options are:
Create /etc/hosts for the container. By default, container engines manage
/etc/hosts, automatically adding the container's own IP address.

**oom_score_adj**=0

Tune the host's OOM preferences for containers (accepts values from -1000 to 1000).

**pidns**="private"

Default way to to create a PID namespace for the container.
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ type ContainersConfig struct {
// NoHosts tells container engine whether to create its own /etc/hosts
NoHosts bool `toml:"no_hosts,omitempty"`

// OOMScoreAdj tunes the host's OOM preferences for containers
// (accepts values from -1000 to 1000).
OOMScoreAdj *int `toml:"oom_score_adj,omitempty"`

// PidsLimit is the number of processes each container is restricted to
// by the cgroup process number controller.
PidsLimit int64 `toml:"pids_limit,omitempty,omitzero"`
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ image_copy_tmp_dir="storage"`
gomega.Expect(err).To(gomega.BeNil())
gomega.Expect(dbBackend).To(gomega.BeEquivalentTo(DBBackendSQLite))
gomega.Expect(config.Containers.CgroupConf).To(gomega.Equal(cgroupConf))
gomega.Expect(*config.Containers.OOMScoreAdj).To(gomega.Equal(int(750)))
})

It("contents of passed-in file should override others", func() {
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/containers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ default_sysctls = [
#
#no_hosts = false

# Tune the host's OOM preferences for containers
# (accepts values from -1000 to 1000).
#oom_score_adj = 0

# Default way to to create a PID namespace for the container
# Options are:
# `private` Create private PID Namespace for the container.
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/testdata/containers_default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ label = true
# limit is never exceeded.
log_size_max = -1

oom_score_adj = 750

# Maximum number of processes allowed in a container.
pids_limit = 2048

Expand Down