Skip to content

Commit 4c6ed57

Browse files
committed
chore: add oomScoreAdj to inspect response
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent ac061b4 commit 4c6ed57

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/inspecttypes/dockercompat/dockercompat.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ type HostConfig struct {
160160
DNS []string `json:"Dns"` // List of DNS server to lookup
161161
DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for
162162
DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for
163+
OomScoreAdj int // specifies the tune container’s OOM preferences (-1000 to 1000, rootless: 100 to 1000)
163164
}
164165

165166
// From https://github.com/moby/moby/blob/v20.10.1/api/types/types.go#L416-L427
@@ -446,6 +447,9 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
446447
c.HostConfig.DNSOptions = dnsSettings.DNSResolvConfOptions
447448
c.HostConfig.DNSSearch = dnsSettings.DNSSearchDomains
448449

450+
oomScoreAdj, _ := getOomScoreAdjFromNative(n.Spec.(*specs.Spec))
451+
c.HostConfig.OomScoreAdj = oomScoreAdj
452+
449453
c.State = cs
450454
c.Config = &Config{
451455
Labels: n.Labels,
@@ -728,6 +732,14 @@ func getDnsFromNative(Labels map[string]string) (*DNSSettings, error) {
728732
return res, nil
729733
}
730734

735+
func getOomScoreAdjFromNative(sp *specs.Spec) (int, error) {
736+
var res int
737+
if sp.Process != nil && sp.Process.OOMScoreAdj != nil {
738+
res = *sp.Process.OOMScoreAdj
739+
}
740+
return res, nil
741+
}
742+
731743
type IPAMConfig struct {
732744
Subnet string `json:"Subnet,omitempty"`
733745
Gateway string `json:"Gateway,omitempty"`

0 commit comments

Comments
 (0)