Skip to content

Commit 6f28dd3

Browse files
marquizklihub
authored andcommitted
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 <markus.lehtonen@intel.com>
1 parent 2d464a3 commit 6f28dd3

8 files changed

Lines changed: 324 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ 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+
}
519+
515520
if v := rdt.GetClosId(); v != nil {
516521
if err := r.owners.ClaimRdtClosID(id, plugin); err != nil {
517522
return err

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())

0 commit comments

Comments
 (0)