Skip to content

Commit cbc87ec

Browse files
committed
createContainer: include linux device cgroups in adjustment application logic
Signed-off-by: Karl Baumgartner <[email protected]>
1 parent 3b4be38 commit cbc87ec

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
@@ -693,6 +693,11 @@ func (r *result) adjustResources(resources *LinuxResources, plugin string) error
693693
reply.HugepageLimits = append(reply.HugepageLimits, l)
694694
}
695695

696+
for _, d := range resources.Devices {
697+
container.Devices = append(container.Devices, d)
698+
reply.Devices = append(reply.Devices, d)
699+
}
700+
696701
if len(resources.Unified) != 0 {
697702
for k, v := range resources.Unified {
698703
if err := r.owners.claimUnified(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
@@ -276,6 +276,9 @@ func (g *Generator) AdjustResources(r *nri.LinuxResources) error {
276276
if v := r.GetPids(); v != nil {
277277
g.SetLinuxResourcesPidsLimit(v.GetLimit())
278278
}
279+
for _, d := range r.Devices {
280+
g.AddLinuxResourcesDevice(d.Allow, d.Type, d.Major.Get(), d.Minor.Get(), d.Access)
281+
}
279282
if g.checkResources != nil {
280283
if err := g.checkResources(g.Config.Linux.Resources); err != nil {
281284
return fmt.Errorf("failed to adjust resources in OCI Spec: %w", err)

0 commit comments

Comments
 (0)