Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 79679f6

Browse files
committed
Add oom_score_adj
Signed-off-by: Josh Curl <[email protected]>
1 parent a14c3da commit 79679f6

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

config/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type ServiceConfigV1 struct {
4646
MemSwapLimit yaml.StringorInt `yaml:"memswap_limit,omitempty"`
4747
Name string `yaml:"name,omitempty"`
4848
Net string `yaml:"net,omitempty"`
49+
OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"`
4950
Pid string `yaml:"pid,omitempty"`
5051
Uts string `yaml:"uts,omitempty"`
5152
Ipc string `yaml:"ipc,omitempty"`
@@ -111,6 +112,7 @@ type ServiceConfig struct {
111112
MemSwapLimit yaml.StringorInt `yaml:"memswap_limit,omitempty"`
112113
NetworkMode string `yaml:"network_mode,omitempty"`
113114
Networks *yaml.Networks `yaml:"networks,omitempty"`
115+
OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"`
114116
Pid string `yaml:"pid,omitempty"`
115117
Ports []string `yaml:"ports,omitempty"`
116118
Privileged bool `yaml:"privileged,omitempty"`

docker/service/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ func Convert(c *config.ServiceConfig, ctx project.Context, clientFactory compose
254254
},
255255
NetworkMode: container.NetworkMode(networkMode),
256256
ReadonlyRootfs: c.ReadOnly,
257+
OomScoreAdj: int(c.OomScoreAdj),
257258
PidMode: container.PidMode(c.Pid),
258259
UTSMode: container.UTSMode(c.Uts),
259260
IpcMode: container.IpcMode(c.Ipc),

docker/service/convert_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ func TestParseLabels(t *testing.T) {
8181
assert.Equal(t, []string{"less"}, []string(cfg.Entrypoint))
8282
}
8383

84+
func TestOomScoreAdj(t *testing.T) {
85+
ctx := &ctx.Context{}
86+
sc := &config.ServiceConfig{
87+
OomScoreAdj: 500,
88+
}
89+
_, hostCfg, err := Convert(sc, ctx.Context, nil)
90+
assert.Nil(t, err)
91+
92+
assert.Equal(t, 500, hostCfg.OomScoreAdj)
93+
}
94+
8495
func TestStopSignal(t *testing.T) {
8596
ctx := &ctx.Context{}
8697
sc := &config.ServiceConfig{

0 commit comments

Comments
 (0)