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

Commit f12d146

Browse files
authored
Merge pull request #406 from joshwget/oom-kill-disable
Add oom_kill_disable
2 parents 7c59e34 + 42066b8 commit f12d146

File tree

3 files changed

+124
-110
lines changed

3 files changed

+124
-110
lines changed

config/types.go

Lines changed: 112 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -19,61 +19,62 @@ type ResourceLookup interface {
1919

2020
// ServiceConfigV1 holds version 1 of libcompose service configuration
2121
type ServiceConfigV1 struct {
22-
Build string `yaml:"build,omitempty"`
23-
CapAdd []string `yaml:"cap_add,omitempty"`
24-
CapDrop []string `yaml:"cap_drop,omitempty"`
25-
CgroupParent string `yaml:"cgroup_parent,omitempty"`
26-
CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"`
27-
CPUSet string `yaml:"cpuset,omitempty"`
28-
CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"`
29-
Command yaml.Command `yaml:"command,flow,omitempty"`
30-
ContainerName string `yaml:"container_name,omitempty"`
31-
Devices []string `yaml:"devices,omitempty"`
32-
DNS yaml.Stringorslice `yaml:"dns,omitempty"`
33-
DNSOpts []string `yaml:"dns_opt,omitempty"`
34-
DNSSearch yaml.Stringorslice `yaml:"dns_search,omitempty"`
35-
Dockerfile string `yaml:"dockerfile,omitempty"`
36-
DomainName string `yaml:"domainname,omitempty"`
37-
Entrypoint yaml.Command `yaml:"entrypoint,flow,omitempty"`
38-
EnvFile yaml.Stringorslice `yaml:"env_file,omitempty"`
39-
Environment yaml.MaporEqualSlice `yaml:"environment,omitempty"`
40-
GroupAdd []string `yaml:"group_add,omitempty"`
41-
Hostname string `yaml:"hostname,omitempty"`
42-
Image string `yaml:"image,omitempty"`
43-
Isolation string `yaml:"isolation,omitempty"`
44-
Labels yaml.SliceorMap `yaml:"labels,omitempty"`
45-
Links yaml.MaporColonSlice `yaml:"links,omitempty"`
46-
LogDriver string `yaml:"log_driver,omitempty"`
47-
MacAddress string `yaml:"mac_address,omitempty"`
48-
MemLimit yaml.MemStringorInt `yaml:"mem_limit,omitempty"`
49-
MemSwapLimit yaml.MemStringorInt `yaml:"memswap_limit,omitempty"`
50-
MemSwappiness yaml.MemStringorInt `yaml:"mem_swappiness,omitempty"`
51-
Name string `yaml:"name,omitempty"`
52-
Net string `yaml:"net,omitempty"`
53-
OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"`
54-
Pid string `yaml:"pid,omitempty"`
55-
Uts string `yaml:"uts,omitempty"`
56-
Ipc string `yaml:"ipc,omitempty"`
57-
Ports []string `yaml:"ports,omitempty"`
58-
Privileged bool `yaml:"privileged,omitempty"`
59-
Restart string `yaml:"restart,omitempty"`
60-
ReadOnly bool `yaml:"read_only,omitempty"`
61-
ShmSize yaml.MemStringorInt `yaml:"shm_size,omitempty"`
62-
StdinOpen bool `yaml:"stdin_open,omitempty"`
63-
SecurityOpt []string `yaml:"security_opt,omitempty"`
64-
StopSignal string `yaml:"stop_signal,omitempty"`
65-
Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"`
66-
Tty bool `yaml:"tty,omitempty"`
67-
User string `yaml:"user,omitempty"`
68-
VolumeDriver string `yaml:"volume_driver,omitempty"`
69-
Volumes []string `yaml:"volumes,omitempty"`
70-
VolumesFrom []string `yaml:"volumes_from,omitempty"`
71-
WorkingDir string `yaml:"working_dir,omitempty"`
72-
Expose []string `yaml:"expose,omitempty"`
73-
ExternalLinks []string `yaml:"external_links,omitempty"`
74-
LogOpt map[string]string `yaml:"log_opt,omitempty"`
75-
ExtraHosts []string `yaml:"extra_hosts,omitempty"`
76-
Ulimits yaml.Ulimits `yaml:"ulimits,omitempty"`
22+
Build string `yaml:"build,omitempty"`
23+
CapAdd []string `yaml:"cap_add,omitempty"`
24+
CapDrop []string `yaml:"cap_drop,omitempty"`
25+
CgroupParent string `yaml:"cgroup_parent,omitempty"`
26+
CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"`
27+
CPUSet string `yaml:"cpuset,omitempty"`
28+
CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"`
29+
Command yaml.Command `yaml:"command,flow,omitempty"`
30+
ContainerName string `yaml:"container_name,omitempty"`
31+
Devices []string `yaml:"devices,omitempty"`
32+
DNS yaml.Stringorslice `yaml:"dns,omitempty"`
33+
DNSOpts []string `yaml:"dns_opt,omitempty"`
34+
DNSSearch yaml.Stringorslice `yaml:"dns_search,omitempty"`
35+
Dockerfile string `yaml:"dockerfile,omitempty"`
36+
DomainName string `yaml:"domainname,omitempty"`
37+
Entrypoint yaml.Command `yaml:"entrypoint,flow,omitempty"`
38+
EnvFile yaml.Stringorslice `yaml:"env_file,omitempty"`
39+
Environment yaml.MaporEqualSlice `yaml:"environment,omitempty"`
40+
GroupAdd []string `yaml:"group_add,omitempty"`
41+
Hostname string `yaml:"hostname,omitempty"`
42+
Image string `yaml:"image,omitempty"`
43+
Isolation string `yaml:"isolation,omitempty"`
44+
Labels yaml.SliceorMap `yaml:"labels,omitempty"`
45+
Links yaml.MaporColonSlice `yaml:"links,omitempty"`
46+
LogDriver string `yaml:"log_driver,omitempty"`
47+
MacAddress string `yaml:"mac_address,omitempty"`
48+
MemLimit yaml.MemStringorInt `yaml:"mem_limit,omitempty"`
49+
MemSwapLimit yaml.MemStringorInt `yaml:"memswap_limit,omitempty"`
50+
MemSwappiness yaml.MemStringorInt `yaml:"mem_swappiness,omitempty"`
51+
Name string `yaml:"name,omitempty"`
52+
Net string `yaml:"net,omitempty"`
53+
OomKillDisable bool `yaml:"oom_kill_disable,omitempty"`
54+
OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"`
55+
Pid string `yaml:"pid,omitempty"`
56+
Uts string `yaml:"uts,omitempty"`
57+
Ipc string `yaml:"ipc,omitempty"`
58+
Ports []string `yaml:"ports,omitempty"`
59+
Privileged bool `yaml:"privileged,omitempty"`
60+
Restart string `yaml:"restart,omitempty"`
61+
ReadOnly bool `yaml:"read_only,omitempty"`
62+
ShmSize yaml.MemStringorInt `yaml:"shm_size,omitempty"`
63+
StdinOpen bool `yaml:"stdin_open,omitempty"`
64+
SecurityOpt []string `yaml:"security_opt,omitempty"`
65+
StopSignal string `yaml:"stop_signal,omitempty"`
66+
Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"`
67+
Tty bool `yaml:"tty,omitempty"`
68+
User string `yaml:"user,omitempty"`
69+
VolumeDriver string `yaml:"volume_driver,omitempty"`
70+
Volumes []string `yaml:"volumes,omitempty"`
71+
VolumesFrom []string `yaml:"volumes_from,omitempty"`
72+
WorkingDir string `yaml:"working_dir,omitempty"`
73+
Expose []string `yaml:"expose,omitempty"`
74+
ExternalLinks []string `yaml:"external_links,omitempty"`
75+
LogOpt map[string]string `yaml:"log_opt,omitempty"`
76+
ExtraHosts []string `yaml:"extra_hosts,omitempty"`
77+
Ulimits yaml.Ulimits `yaml:"ulimits,omitempty"`
7778
}
7879

7980
// Log holds v2 logging information
@@ -84,61 +85,62 @@ type Log struct {
8485

8586
// ServiceConfig holds version 2 of libcompose service configuration
8687
type ServiceConfig struct {
87-
Build yaml.Build `yaml:"build,omitempty"`
88-
CapAdd []string `yaml:"cap_add,omitempty"`
89-
CapDrop []string `yaml:"cap_drop,omitempty"`
90-
CPUSet string `yaml:"cpuset,omitempty"`
91-
CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"`
92-
CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"`
93-
Command yaml.Command `yaml:"command,flow,omitempty"`
94-
CgroupParent string `yaml:"cgroup_parent,omitempty"`
95-
ContainerName string `yaml:"container_name,omitempty"`
96-
Devices []string `yaml:"devices,omitempty"`
97-
DependsOn []string `yaml:"depends_on,omitempty"`
98-
DNS yaml.Stringorslice `yaml:"dns,omitempty"`
99-
DNSOpts []string `yaml:"dns_opt,omitempty"`
100-
DNSSearch yaml.Stringorslice `yaml:"dns_search,omitempty"`
101-
DomainName string `yaml:"domainname,omitempty"`
102-
Entrypoint yaml.Command `yaml:"entrypoint,flow,omitempty"`
103-
EnvFile yaml.Stringorslice `yaml:"env_file,omitempty"`
104-
Environment yaml.MaporEqualSlice `yaml:"environment,omitempty"`
105-
Expose []string `yaml:"expose,omitempty"`
106-
Extends yaml.MaporEqualSlice `yaml:"extends,omitempty"`
107-
ExternalLinks []string `yaml:"external_links,omitempty"`
108-
ExtraHosts []string `yaml:"extra_hosts,omitempty"`
109-
GroupAdd []string `yaml:"group_add,omitempty"`
110-
Image string `yaml:"image,omitempty"`
111-
Isolation string `yaml:"isolation,omitempty"`
112-
Hostname string `yaml:"hostname,omitempty"`
113-
Ipc string `yaml:"ipc,omitempty"`
114-
Labels yaml.SliceorMap `yaml:"labels,omitempty"`
115-
Links yaml.MaporColonSlice `yaml:"links,omitempty"`
116-
Logging Log `yaml:"logging,omitempty"`
117-
MacAddress string `yaml:"mac_address,omitempty"`
118-
MemLimit yaml.MemStringorInt `yaml:"mem_limit,omitempty"`
119-
MemSwapLimit yaml.MemStringorInt `yaml:"memswap_limit,omitempty"`
120-
MemSwappiness yaml.MemStringorInt `yaml:"mem_swappiness,omitempty"`
121-
NetworkMode string `yaml:"network_mode,omitempty"`
122-
Networks *yaml.Networks `yaml:"networks,omitempty"`
123-
OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"`
124-
Pid string `yaml:"pid,omitempty"`
125-
Ports []string `yaml:"ports,omitempty"`
126-
Privileged bool `yaml:"privileged,omitempty"`
127-
SecurityOpt []string `yaml:"security_opt,omitempty"`
128-
ShmSize yaml.MemStringorInt `yaml:"shm_size,omitempty"`
129-
StopSignal string `yaml:"stop_signal,omitempty"`
130-
Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"`
131-
VolumeDriver string `yaml:"volume_driver,omitempty"`
132-
Volumes *yaml.Volumes `yaml:"volumes,omitempty"`
133-
VolumesFrom []string `yaml:"volumes_from,omitempty"`
134-
Uts string `yaml:"uts,omitempty"`
135-
Restart string `yaml:"restart,omitempty"`
136-
ReadOnly bool `yaml:"read_only,omitempty"`
137-
StdinOpen bool `yaml:"stdin_open,omitempty"`
138-
Tty bool `yaml:"tty,omitempty"`
139-
User string `yaml:"user,omitempty"`
140-
WorkingDir string `yaml:"working_dir,omitempty"`
141-
Ulimits yaml.Ulimits `yaml:"ulimits,omitempty"`
88+
Build yaml.Build `yaml:"build,omitempty"`
89+
CapAdd []string `yaml:"cap_add,omitempty"`
90+
CapDrop []string `yaml:"cap_drop,omitempty"`
91+
CPUSet string `yaml:"cpuset,omitempty"`
92+
CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"`
93+
CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"`
94+
Command yaml.Command `yaml:"command,flow,omitempty"`
95+
CgroupParent string `yaml:"cgroup_parent,omitempty"`
96+
ContainerName string `yaml:"container_name,omitempty"`
97+
Devices []string `yaml:"devices,omitempty"`
98+
DependsOn []string `yaml:"depends_on,omitempty"`
99+
DNS yaml.Stringorslice `yaml:"dns,omitempty"`
100+
DNSOpts []string `yaml:"dns_opt,omitempty"`
101+
DNSSearch yaml.Stringorslice `yaml:"dns_search,omitempty"`
102+
DomainName string `yaml:"domainname,omitempty"`
103+
Entrypoint yaml.Command `yaml:"entrypoint,flow,omitempty"`
104+
EnvFile yaml.Stringorslice `yaml:"env_file,omitempty"`
105+
Environment yaml.MaporEqualSlice `yaml:"environment,omitempty"`
106+
Expose []string `yaml:"expose,omitempty"`
107+
Extends yaml.MaporEqualSlice `yaml:"extends,omitempty"`
108+
ExternalLinks []string `yaml:"external_links,omitempty"`
109+
ExtraHosts []string `yaml:"extra_hosts,omitempty"`
110+
GroupAdd []string `yaml:"group_add,omitempty"`
111+
Image string `yaml:"image,omitempty"`
112+
Isolation string `yaml:"isolation,omitempty"`
113+
Hostname string `yaml:"hostname,omitempty"`
114+
Ipc string `yaml:"ipc,omitempty"`
115+
Labels yaml.SliceorMap `yaml:"labels,omitempty"`
116+
Links yaml.MaporColonSlice `yaml:"links,omitempty"`
117+
Logging Log `yaml:"logging,omitempty"`
118+
MacAddress string `yaml:"mac_address,omitempty"`
119+
MemLimit yaml.MemStringorInt `yaml:"mem_limit,omitempty"`
120+
MemSwapLimit yaml.MemStringorInt `yaml:"memswap_limit,omitempty"`
121+
MemSwappiness yaml.MemStringorInt `yaml:"mem_swappiness,omitempty"`
122+
NetworkMode string `yaml:"network_mode,omitempty"`
123+
Networks *yaml.Networks `yaml:"networks,omitempty"`
124+
OomKillDisable bool `yaml:"oom_kill_disable,omitempty"`
125+
OomScoreAdj yaml.StringorInt `yaml:"oom_score_adj,omitempty"`
126+
Pid string `yaml:"pid,omitempty"`
127+
Ports []string `yaml:"ports,omitempty"`
128+
Privileged bool `yaml:"privileged,omitempty"`
129+
SecurityOpt []string `yaml:"security_opt,omitempty"`
130+
ShmSize yaml.MemStringorInt `yaml:"shm_size,omitempty"`
131+
StopSignal string `yaml:"stop_signal,omitempty"`
132+
Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"`
133+
VolumeDriver string `yaml:"volume_driver,omitempty"`
134+
Volumes *yaml.Volumes `yaml:"volumes,omitempty"`
135+
VolumesFrom []string `yaml:"volumes_from,omitempty"`
136+
Uts string `yaml:"uts,omitempty"`
137+
Restart string `yaml:"restart,omitempty"`
138+
ReadOnly bool `yaml:"read_only,omitempty"`
139+
StdinOpen bool `yaml:"stdin_open,omitempty"`
140+
Tty bool `yaml:"tty,omitempty"`
141+
User string `yaml:"user,omitempty"`
142+
WorkingDir string `yaml:"working_dir,omitempty"`
143+
Ulimits yaml.Ulimits `yaml:"ulimits,omitempty"`
142144
}
143145

144146
// VolumeConfig holds v2 volume configuration

docker/service/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func Convert(c *config.ServiceConfig, ctx project.Context, clientFactory compose
193193
CpusetCpus: c.CPUSet,
194194
Ulimits: ulimits,
195195
Devices: deviceMappings,
196+
OomKillDisable: &c.OomKillDisable,
196197
}
197198

198199
networkMode := c.NetworkMode

docker/service/convert_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ func TestMemSwappiness(t *testing.T) {
138138
assert.Equal(t, int64(10), *hostCfg.MemorySwappiness)
139139
}
140140

141+
func TestOomKillDisable(t *testing.T) {
142+
ctx := &ctx.Context{}
143+
sc := &config.ServiceConfig{
144+
OomKillDisable: true,
145+
}
146+
_, hostCfg, err := Convert(sc, ctx.Context, nil)
147+
assert.Nil(t, err)
148+
149+
assert.Equal(t, true, *hostCfg.OomKillDisable)
150+
}
151+
141152
func TestOomScoreAdj(t *testing.T) {
142153
ctx := &ctx.Context{}
143154
sc := &config.ServiceConfig{

0 commit comments

Comments
 (0)