Skip to content

Commit fcd3e39

Browse files
authored
Merge pull request #168 from karlbaumg/device-cgroup-fix
Include linux device cgroups in adjustment logic
2 parents fa3cd41 + cbc87ec commit fcd3e39

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

pkg/adaptation/result.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,11 @@ func (r *result) adjustResources(resources *LinuxResources, plugin string) error
749749
reply.HugepageLimits = append(reply.HugepageLimits, l)
750750
}
751751

752+
for _, d := range resources.Devices {
753+
container.Devices = append(container.Devices, d)
754+
reply.Devices = append(reply.Devices, d)
755+
}
756+
752757
if len(resources.Unified) != 0 {
753758
for k, v := range resources.Unified {
754759
if err := r.owners.ClaimCgroupsUnified(id, k, plugin); err != nil {

pkg/api/resources.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ func (r *LinuxResources) Copy() *LinuxResources {
189189
}
190190
o.BlockioClass = String(r.BlockioClass)
191191
o.RdtClass = String(r.RdtClass)
192+
for _, d := range r.Devices {
193+
o.Devices = append(o.Devices, &LinuxDeviceCgroup{
194+
Allow: d.Allow,
195+
Type: d.Type,
196+
Access: d.Access,
197+
Major: Int64(d.Major),
198+
Minor: Int64(d.Minor),
199+
})
200+
}
192201

193202
return o
194203
}

pkg/runtime-tools/generate/generate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ func (g *Generator) AdjustResources(r *nri.LinuxResources) error {
284284
if v := r.GetPids(); v != nil {
285285
g.SetLinuxResourcesPidsLimit(v.GetLimit())
286286
}
287+
for _, d := range r.Devices {
288+
g.AddLinuxResourcesDevice(d.Allow, d.Type, d.Major.Get(), d.Minor.Get(), d.Access)
289+
}
287290
if g.checkResources != nil {
288291
if err := g.checkResources(g.Config.Linux.Resources); err != nil {
289292
return fmt.Errorf("failed to adjust resources in OCI Spec: %w", err)

0 commit comments

Comments
 (0)