Skip to content

Commit ec11b58

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.
1 parent a514460 commit ec11b58

File tree

8 files changed

+298
-226
lines changed

8 files changed

+298
-226
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
@@ -879,6 +879,7 @@ var _ = Describe("Plugin container creation adjustments", func() {
879879
&api.ContainerAdjustment{
880880
Linux: &api.LinuxContainerAdjustment{
881881
Rdt: &api.LinuxRdt{
882+
ClosId: api.String("test"),
882883
Schemata: api.RepeatedString([]string{"L3:0=ff", "MB:0=50"}),
883884
EnableMonitoring: api.Bool(true),
884885
},

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
@@ -297,6 +297,12 @@ func (a *ContainerAdjustment) SetLinuxRDTEnableMonitoring(value bool) {
297297
a.Linux.Rdt.EnableMonitoring = Bool(value)
298298
}
299299

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

pkg/api/api.pb.go

Lines changed: 233 additions & 222 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
@@ -560,6 +560,8 @@ message LinuxRdt {
560560
OptionalString clos_id = 1;
561561
OptionalRepeatedString schemata = 2;
562562
OptionalBool enable_monitoring = 3;
563+
// NRI specific field to mark the RDT config for removal.
564+
bool remove = 4;
563565
}
564566

565567
// 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
@@ -201,6 +201,10 @@ func (o *OwningPlugins) ClearArgs(id, plugin string) {
201201
o.mustOwnersFor(id).ClearArgs(plugin)
202202
}
203203

204+
func (o *OwningPlugins) ClearRdt(id, plugin string) {
205+
o.mustOwnersFor(id).ClearRdt(plugin)
206+
}
207+
204208
func (o *OwningPlugins) AnnotationOwner(id, key string) (string, bool) {
205209
return o.ownersFor(id).compoundOwner(Field_Annotations.Key(), key)
206210
}
@@ -613,6 +617,12 @@ func (f *FieldOwners) ClearArgs(plugin string) {
613617
f.clearSimple(Field_Args.Key(), plugin)
614618
}
615619

620+
func (f *FieldOwners) ClearRdt(plugin string) {
621+
f.clearSimple(Field_RdtClosID.Key(), plugin)
622+
f.clearSimple(Field_RdtSchemata.Key(), plugin)
623+
f.clearSimple(Field_RdtEnableMonitoring.Key(), plugin)
624+
}
625+
616626
func (f *FieldOwners) Conflict(field int32, plugin, other string, qualifiers ...string) error {
617627
return fmt.Errorf("plugins %q and %q both tried to set %s",
618628
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
@@ -344,6 +344,10 @@ func (g *Generator) AdjustRdt(r *nri.LinuxRdt) {
344344
return
345345
}
346346

347+
if r.Remove {
348+
g.ClearLinuxIntelRdt()
349+
}
350+
347351
g.AdjustRdtClosID(r.ClosId.Get())
348352
g.AdjustRdtSchemata(r.Schemata.Get())
349353
g.AdjustRdtEnableMonitoring(r.EnableMonitoring.Get())

0 commit comments

Comments
 (0)