diff --git a/cmd/plugins/topology-aware/policy/cache_test.go b/cmd/plugins/topology-aware/policy/cache_test.go index a3696d0cd..7ce1a7b80 100644 --- a/cmd/plugins/topology-aware/policy/cache_test.go +++ b/cmd/plugins/topology-aware/policy/cache_test.go @@ -88,11 +88,11 @@ func TestAllocationMarshalling(t *testing.T) { }{ { name: "non-zero Exclusive", - data: []byte(`{"key1":{"Exclusive":"1","Part":1,"CPUType":0,"Container":"1","Pool":"testnode","MemoryPool":0,"MemType":"DRAM,PMEM,HBM","MemSize":0,"ColdStart":0}}`), + data: []byte(`{"key1":{"PrettyName":"","Exclusive":"1","Part":1,"CPUType":0,"Container":"1","Pool":"testnode","MemoryPool":0,"MemType":"DRAM,PMEM,HBM","MemSize":0,"ColdStart":0}}`), }, { name: "zero Exclusive", - data: []byte(`{"key1":{"Exclusive":"","Part":1,"CPUType":0,"Container":"1","Pool":"testnode","MemoryPool":0,"MemType":"DRAM,PMEM,HBM","MemSize":0,"ColdStart":0}}`), + data: []byte(`{"key1":{"PrettyName":"","Exclusive":"","Part":1,"CPUType":0,"Container":"1","Pool":"testnode","MemoryPool":0,"MemType":"DRAM,PMEM,HBM","MemSize":0,"ColdStart":0}}`), }, } for _, tc := range tcases { diff --git a/cmd/plugins/topology-aware/policy/mocks_test.go b/cmd/plugins/topology-aware/policy/mocks_test.go index d9e7c6c21..f9b2da507 100644 --- a/cmd/plugins/topology-aware/policy/mocks_test.go +++ b/cmd/plugins/topology-aware/policy/mocks_test.go @@ -19,6 +19,7 @@ import ( "time" nri "github.com/containerd/nri/pkg/api" + "github.com/containers/nri-plugins/pkg/agent/podresapi" resmgr "github.com/containers/nri-plugins/pkg/apis/resmgr/v1alpha1" "github.com/containers/nri-plugins/pkg/cpuallocator" "github.com/containers/nri-plugins/pkg/resmgr/cache" @@ -324,6 +325,9 @@ func (fake *mockSystem) SetCpusOnline(online bool, cpus idset.IDSet) (idset.IDSe func (fake *mockSystem) NodeDistance(idset.ID, idset.ID) int { return 10 } +func (fake *mockSystem) NodeHintToCPUs(string) string { + return "" +} type mockContainer struct { name string @@ -538,6 +542,9 @@ func (m *mockContainer) PreserveMemoryResources() bool { func (m *mockContainer) MemoryTypes() (libmem.TypeMask, error) { return libmem.TypeMaskDRAM, nil } +func (m *mockContainer) GetPodResources() *podresapi.ContainerResources { + return nil +} type mockPod struct { name string @@ -625,6 +632,9 @@ func (m *mockPod) GetTasks(bool) ([]string, error) { func (m *mockPod) GetCtime() time.Time { panic("unimplemented") } +func (m *mockPod) GetPodResources() *podresapi.PodResources { + return nil +} type mockCache struct { returnValueForGetPolicyEntry bool @@ -632,7 +642,7 @@ type mockCache struct { returnValue2ForLookupContainer bool } -func (m *mockCache) InsertPod(*nri.PodSandbox) (cache.Pod, error) { +func (m *mockCache) InsertPod(*nri.PodSandbox, <-chan *podresapi.PodResources) cache.Pod { panic("unimplemented") } func (m *mockCache) DeletePod(string) cache.Pod { @@ -695,7 +705,7 @@ func (m *mockCache) GetPolicyEntry(string, interface{}) bool { func (m *mockCache) Save() error { return nil } -func (m *mockCache) RefreshPods([]*nri.PodSandbox) ([]cache.Pod, []cache.Pod, []cache.Container) { +func (m *mockCache) RefreshPods([]*nri.PodSandbox, <-chan podresapi.PodResourcesList) ([]cache.Pod, []cache.Pod, []cache.Container) { panic("unimplemented") } func (m *mockCache) RefreshContainers([]*nri.Container) ([]cache.Container, []cache.Container) { diff --git a/docs/resource-policy/policy/topology-aware.md b/docs/resource-policy/policy/topology-aware.md index 103dc94bb..cebdd3297 100644 --- a/docs/resource-policy/policy/topology-aware.md +++ b/docs/resource-policy/policy/topology-aware.md @@ -443,7 +443,7 @@ metadata: prefer-reserved-cpus.resource-policy.nri.io/container.special: "false" ``` -## Allowing or denying mount/device paths via annotations +## Controlling Topology Hints Via Annotations User is able mark certain pods and containers to have allowed or denied paths for mounts or devices. What this means is that when the system @@ -486,6 +486,16 @@ metadata: - /xy-zy/another-blacklisted-path5 ``` +## Using Pod Resource API for Extra Topology Hints + +If access to the `kubelet`'s `Pod Resource API` is enabled in the +[Node Agent's](../developers-guide/architecture.md#node-agent) configuration, +it is automatically used to generate per-container topology hints when a +device with locality to a NUMA node is advertised by the API. Annotated allow +and deny lists can be used to selective disable or enable per-resource hints, +using `podresapi:$RESOURCE_NAME` as the path. + + ## Container Affinity and Anti-Affinity ### Introduction