Skip to content

Commit 8c0c9f6

Browse files
committed
Implement removal of RDT
Makes it possible to remove/override the linux.intelRdt object from the container configuration. Extend the API by adding new 'Remove' field to the LinuxRdt message which is used as a marker to fully delete/override the IntelRdt configuration. This patch also updates the adaptation and runtime-tools correspondingly. Signed-off-by: Markus Lehtonen <[email protected]>
1 parent dfbae8a commit 8c0c9f6

9 files changed

Lines changed: 350 additions & 253 deletions

File tree

pkg/adaptation/adaptation_suite_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,11 @@ var _ = Describe("Plugin container creation adjustments", func() {
610610
)
611611
case "rdt":
612612
if overwrite {
613-
a.SetLinuxRDTClosID(p.name)
614-
} else {
615-
a.SetLinuxRDTSchemata([]string{"L3:0=ff", "MB:0=50"})
616-
a.SetLinuxRDTEnableMonitoring(true)
613+
a.RemoveLinuxRDT()
617614
}
615+
a.SetLinuxRDTClosID(p.name)
616+
a.SetLinuxRDTSchemata([]string{"L3:0=ff", "MB:0=50"})
617+
a.SetLinuxRDTEnableMonitoring(true)
618618
}
619619

620620
return a, nil, nil
@@ -959,6 +959,7 @@ var _ = Describe("Plugin container creation adjustments", func() {
959959
&api.ContainerAdjustment{
960960
Linux: &api.LinuxContainerAdjustment{
961961
Rdt: &api.LinuxRdt{
962+
ClosId: api.String("test"),
962963
Schemata: api.RepeatedString([]string{"L3:0=ff", "MB:0=50"}),
963964
EnableMonitoring: api.Bool(true),
964965
},

pkg/adaptation/result.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,23 +512,34 @@ func (r *result) adjustRdt(rdt *LinuxRdt, plugin string) error {
512512

513513
id := r.request.create.Container.Id
514514

515+
if rdt.GetRemove() {
516+
r.owners.ClearRdt(id, plugin)
517+
r.reply.adjust.Linux.Rdt = &LinuxRdt{
518+
// Propagate the remove request (if not overridden below).
519+
Remove: true,
520+
}
521+
}
522+
515523
if v := rdt.GetClosId(); v != nil {
516524
if err := r.owners.ClaimRdtClosID(id, plugin); err != nil {
517525
return err
518526
}
519527
r.reply.adjust.Linux.Rdt.ClosId = String(v.GetValue())
528+
r.reply.adjust.Linux.Rdt.Remove = false
520529
}
521530
if v := rdt.GetSchemata(); v != nil {
522531
if err := r.owners.ClaimRdtSchemata(id, plugin); err != nil {
523532
return err
524533
}
525534
r.reply.adjust.Linux.Rdt.Schemata = RepeatedString(v.GetValue())
535+
r.reply.adjust.Linux.Rdt.Remove = false
526536
}
527537
if v := rdt.GetEnableMonitoring(); v != nil {
528538
if err := r.owners.ClaimRdtEnableMonitoring(id, plugin); err != nil {
529539
return err
530540
}
531541
r.reply.adjust.Linux.Rdt.EnableMonitoring = Bool(v.GetValue())
542+
r.reply.adjust.Linux.Rdt.Remove = false
532543
}
533544

534545
return nil

pkg/api/adjustment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ func (a *ContainerAdjustment) SetLinuxRDTEnableMonitoring(value bool) {
316316
a.Linux.Rdt.EnableMonitoring = Bool(value)
317317
}
318318

319+
// RemoveLinuxRDT records the removal of the RDT configuration.
320+
func (a *ContainerAdjustment) RemoveLinuxRDT() {
321+
a.initLinuxRdt()
322+
a.Linux.Rdt.Remove = true
323+
}
324+
319325
// AddLinuxUnified sets a cgroupv2 unified resource.
320326
func (a *ContainerAdjustment) AddLinuxUnified(key, value string) {
321327
a.initLinuxResourcesUnified()

pkg/api/api.pb.go

Lines changed: 259 additions & 249 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/api.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ message LinuxRdt {
612612
OptionalString clos_id = 1;
613613
OptionalRepeatedString schemata = 2;
614614
OptionalBool enable_monitoring = 3;
615+
// NRI specific field to mark the RDT config for removal.
616+
bool remove = 4;
615617
}
616618

617619
// KeyValue represents an environment variable.

pkg/api/api_vtproto.pb.go

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/owners.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ func (o *OwningPlugins) ClearLinuxNetDevice(id, path, plugin string) {
224224
o.mustOwnersFor(id).ClearLinuxNetDevice(path, plugin)
225225
}
226226

227+
func (o *OwningPlugins) ClearRdt(id, plugin string) {
228+
o.mustOwnersFor(id).ClearRdt(plugin)
229+
}
230+
227231
func (o *OwningPlugins) AnnotationOwner(id, key string) (string, bool) {
228232
return o.ownersFor(id).compoundOwner(Field_Annotations.Key(), key)
229233
}
@@ -668,6 +672,12 @@ func (f *FieldOwners) ClearLinuxNetDevice(key, plugin string) {
668672
f.clearCompound(Field_LinuxNetDevices.Key(), key, plugin)
669673
}
670674

675+
func (f *FieldOwners) ClearRdt(plugin string) {
676+
f.clearSimple(Field_RdtClosID.Key(), plugin)
677+
f.clearSimple(Field_RdtSchemata.Key(), plugin)
678+
f.clearSimple(Field_RdtEnableMonitoring.Key(), plugin)
679+
}
680+
671681
func (f *FieldOwners) Conflict(field int32, plugin, other string, qualifiers ...string) error {
672682
return fmt.Errorf("plugins %q and %q both tried to set %s",
673683
plugin, other, qualify(field, qualifiers...))

pkg/runtime-tools/generate/generate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ func (g *Generator) AdjustRdt(r *nri.LinuxRdt) {
396396
return
397397
}
398398

399+
if r.Remove {
400+
g.ClearLinuxIntelRdt()
401+
}
402+
399403
g.AdjustRdtClosID(r.ClosId.Get())
400404
g.AdjustRdtSchemata(r.Schemata.Get())
401405
g.AdjustRdtEnableMonitoring(r.EnableMonitoring.Get())

pkg/runtime-tools/generate/generate_suite_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,26 @@ var _ = Describe("Adjustment", func() {
482482
}))
483483
})
484484
})
485+
When("has a RDT remove adjustment", func() {
486+
It("removes the IntelRdt config", func() {
487+
spec := makeSpec()
488+
spec.Linux.IntelRdt = &rspec.LinuxIntelRdt{ClosID: "bar"}
489+
adjust := &api.ContainerAdjustment{
490+
Linux: &api.LinuxContainerAdjustment{
491+
Rdt: &api.LinuxRdt{
492+
Remove: true,
493+
},
494+
},
495+
}
496+
497+
rg := &rgen.Generator{Config: spec}
498+
xg := xgen.SpecGenerator(rg)
499+
500+
Expect(xg).ToNot(BeNil())
501+
Expect(xg.Adjust(adjust)).To(Succeed())
502+
Expect(spec.Linux.IntelRdt).To(BeNil())
503+
})
504+
})
485505
})
486506

487507
type specOption func(*rspec.Spec)

0 commit comments

Comments
 (0)