Skip to content

Commit d8ca621

Browse files
committed
chore: add oomScoreAdj to inspect response
Signed-off-by: Arjun Raja Yogidas <arjunry@amazon.com>
1 parent cd29dc5 commit d8ca621

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,
@@ -732,6 +736,14 @@ func getDnsFromNative(Labels map[string]string) (*DNSSettings, error) {
732736
return res, nil
733737
}
734738

739+
func getOomScoreAdjFromNative(sp *specs.Spec) (int, error) {
740+
var res int
741+
if sp.Process != nil && sp.Process.OOMScoreAdj != nil {
742+
res = *sp.Process.OOMScoreAdj
743+
}
744+
return res, nil
745+
}
746+
735747
type IPAMConfig struct {
736748
Subnet string `json:"Subnet,omitempty"`
737749
Gateway string `json:"Gateway,omitempty"`

0 commit comments

Comments
 (0)