Skip to content

Commit e6e2d73

Browse files
committed
feat(cgroup1): skip cgroup1 update operation if not configured in LinuxResources
Signed-off-by: Derek Ray <derek9ray@gmail.com>
1 parent 8c81c66 commit e6e2d73

File tree

8 files changed

+30
-1
lines changed

8 files changed

+30
-1
lines changed

cgroup1/blkio.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (b *blkioController) Create(path string, resources *specs.LinuxResources) e
8585
}
8686

8787
func (b *blkioController) Update(path string, resources *specs.LinuxResources) error {
88+
if resources == nil || resources.BlockIO == nil {
89+
return nil
90+
}
91+
8892
return b.Create(path, resources)
8993
}
9094

cgroup1/cpu.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ func (c *cpuController) Create(path string, resources *specs.LinuxResources) err
9696
}
9797

9898
func (c *cpuController) Update(path string, resources *specs.LinuxResources) error {
99+
if resources == nil || resources.CPU == nil || (resources.CPU.Shares == nil && resources.CPU.Period == nil && resources.CPU.Quota == nil) {
100+
return nil
101+
}
102+
99103
return c.Create(path, resources)
100104
}
101105

cgroup1/cpuset.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ func (c *cpusetController) Create(path string, resources *specs.LinuxResources)
8282
}
8383

8484
func (c *cpusetController) Update(path string, resources *specs.LinuxResources) error {
85+
if resources == nil || resources.CPU == nil || (resources.CPU.Cpus == "" && resources.CPU.Mems == "") {
86+
return nil
87+
}
88+
8589
return c.Create(path, resources)
8690
}
8791

cgroup1/devices.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ func (d *devicesController) Create(path string, resources *specs.LinuxResources)
7272
}
7373

7474
func (d *devicesController) Update(path string, resources *specs.LinuxResources) error {
75+
if resources == nil || resources.Devices == nil {
76+
return nil
77+
}
78+
7579
return d.Create(path, resources)
7680
}
7781

cgroup1/memory.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,10 @@ func (m *memoryController) Create(path string, resources *specs.LinuxResources)
210210
}
211211

212212
func (m *memoryController) Update(path string, resources *specs.LinuxResources) error {
213-
if resources.Memory == nil {
213+
if resources == nil || resources.Memory == nil {
214214
return nil
215215
}
216+
216217
g := func(v *int64) bool {
217218
return v != nil && *v > 0
218219
}

cgroup1/net_cls.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@ func (n *netclsController) Create(path string, resources *specs.LinuxResources)
5757
}
5858

5959
func (n *netclsController) Update(path string, resources *specs.LinuxResources) error {
60+
if resources == nil || resources.Network == nil {
61+
return nil
62+
}
63+
6064
return n.Create(path, resources)
6165
}

cgroup1/pids.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func (p *pidsController) Create(path string, resources *specs.LinuxResources) er
5959
}
6060

6161
func (p *pidsController) Update(path string, resources *specs.LinuxResources) error {
62+
if resources == nil || resources.Pids == nil {
63+
return nil
64+
}
65+
6266
return p.Create(path, resources)
6367
}
6468

cgroup1/rdma.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ func (p *rdmaController) Create(path string, resources *specs.LinuxResources) er
7878
}
7979

8080
func (p *rdmaController) Update(path string, resources *specs.LinuxResources) error {
81+
if resources == nil || resources.Rdma == nil {
82+
return nil
83+
}
84+
8185
return p.Create(path, resources)
8286
}
8387

0 commit comments

Comments
 (0)