Skip to content

Commit cdcd76e

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 e5645a6 commit cdcd76e

File tree

8 files changed

+299
-228
lines changed

8 files changed

+299
-228
lines changed

pkg/adaptation/adaptation_suite_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,11 @@ var _ = Describe("Plugin container creation adjustments", func() {
585585
)
586586
case "rdt":
587587
if overwrite {
588-
a.SetLinuxRDTClosID(p.name)
589-
} else {
590-
a.SetLinuxRDTSchemata([]string{"L3:0=ff", "MB:0=50"})
591-
a.SetLinuxRDTEnableMonitoring(true)
588+
a.RemoveLinuxRDT()
592589
}
590+
a.SetLinuxRDTClosID(p.name)
591+
a.SetLinuxRDTSchemata([]string{"L3:0=ff", "MB:0=50"})
592+
a.SetLinuxRDTEnableMonitoring(true)
593593
}
594594

595595
return a, nil, nil
@@ -898,6 +898,7 @@ var _ = Describe("Plugin container creation adjustments", func() {
898898
&api.ContainerAdjustment{
899899
Linux: &api.LinuxContainerAdjustment{
900900
Rdt: &api.LinuxRdt{
901+
ClosId: api.String("test"),
901902
Schemata: api.RepeatedString([]string{"L3:0=ff", "MB:0=50"}),
902903
EnableMonitoring: api.Bool(true),
903904
},

pkg/adaptation/result.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ func (r *result) adjustRdt(rdt *LinuxRdt, plugin string) error {
464464

465465
id := r.request.create.Container.Id
466466

467+
if rdt.GetRemove() {
468+
r.owners.ClearRdt(id, plugin)
469+
r.reply.adjust.Linux.Rdt = &LinuxRdt{}
470+
}
471+
467472
if v := rdt.GetClosId(); v != nil {
468473
if err := r.owners.ClaimRdtClosID(id, plugin); err != nil {
469474
return err

pkg/api/adjustment.go

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

301+
// RemoveLinuxRdt records the removal of the RDT configuration.
302+
func (a *ContainerAdjustment) RemoveLinuxRDT() {
303+
a.initLinuxRdt()
304+
a.Linux.Rdt.Remove = true
305+
}
306+
301307
// AddLinuxUnified sets a cgroupv2 unified resource.
302308
func (a *ContainerAdjustment) AddLinuxUnified(key, value string) {
303309
a.initLinuxResourcesUnified()

pkg/api/api.pb.go

Lines changed: 234 additions & 224 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
@@ -568,6 +568,8 @@ message LinuxRdt {
568568
OptionalString clos_id = 1;
569569
OptionalRepeatedString schemata = 2;
570570
OptionalBool enable_monitoring = 3;
571+
// NRI specific field to mark the RDT config for removal.
572+
bool remove = 4;
571573
}
572574

573575
// 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
@@ -204,6 +204,10 @@ func (o *OwningPlugins) ClearArgs(id, plugin string) {
204204
o.mustOwnersFor(id).ClearArgs(plugin)
205205
}
206206

207+
func (o *OwningPlugins) ClearRdt(id, plugin string) {
208+
o.mustOwnersFor(id).ClearRdt(plugin)
209+
}
210+
207211
func (o *OwningPlugins) AnnotationOwner(id, key string) (string, bool) {
208212
return o.ownersFor(id).compoundOwner(Field_Annotations.Key(), key)
209213
}
@@ -616,6 +620,12 @@ func (f *FieldOwners) ClearArgs(plugin string) {
616620
f.clearSimple(Field_Args.Key(), plugin)
617621
}
618622

623+
func (f *FieldOwners) ClearRdt(plugin string) {
624+
f.clearSimple(Field_RdtClosID.Key(), plugin)
625+
f.clearSimple(Field_RdtSchemata.Key(), plugin)
626+
f.clearSimple(Field_RdtEnableMonitoring.Key(), plugin)
627+
}
628+
619629
func (f *FieldOwners) Conflict(field int32, plugin, other string, qualifiers ...string) error {
620630
return fmt.Errorf("plugins %q and %q both tried to set %s",
621631
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
@@ -387,6 +387,10 @@ func (g *Generator) AdjustRdt(r *nri.LinuxRdt) {
387387
return
388388
}
389389

390+
if r.Remove {
391+
g.ClearLinuxIntelRdt()
392+
}
393+
390394
g.AdjustRdtClosID(r.ClosId.Get())
391395
g.AdjustRdtSchemata(r.Schemata.Get())
392396
g.AdjustRdtEnableMonitoring(r.EnableMonitoring.Get())

0 commit comments

Comments
 (0)