in pkg/noderesourcetopology/filter.go [44:91]
func singleNUMAContainerLevelHandler(lh logr.Logger, pod *v1.Pod, zones topologyv1alpha2.ZoneList, nodeInfo *framework.NodeInfo) *framework.Status {
lh.V(5).Info("container level single NUMA node handler")
// prepare NUMANodes list from zoneMap
nodes := createNUMANodeList(lh, zones)
qos := v1qos.GetPodQOS(pod)
// Node() != nil already verified in Filter(), which is the only public entry point
logNumaNodes(lh, "container handler NUMA resources", nodeInfo.Node().Name, nodes)
// the init containers are running SERIALLY and BEFORE the normal containers.
// https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#understanding-init-containers
// therefore, we don't need to accumulate their resources together
for _, initContainer := range pod.Spec.InitContainers {
// TODO: handle sidecar explicitely (new kind)
clh := lh.WithValues(logging.KeyContainer, initContainer.Name, logging.KeyContainerKind, logging.KindContainerInit)
clh.V(6).Info("desired resources", stringify.ResourceListToLoggable(initContainer.Resources.Requests)...)
_, match := resourcesAvailableInAnyNUMANodes(clh, nodes, initContainer.Resources.Requests, qos, nodeInfo)
if !match {
// we can't align init container, so definitely we can't align a pod
clh.V(2).Info("cannot align container")
return framework.NewStatus(framework.Unschedulable, "cannot align init container")
}
}
for _, container := range pod.Spec.Containers {
clh := lh.WithValues(logging.KeyContainer, container.Name, logging.KeyContainerKind, logging.KindContainerApp)
clh.V(6).Info("container requests", stringify.ResourceListToLoggable(container.Resources.Requests)...)
numaID, match := resourcesAvailableInAnyNUMANodes(clh, nodes, container.Resources.Requests, qos, nodeInfo)
if !match {
// we can't align container, so definitely we can't align a pod
clh.V(2).Info("cannot align container")
return framework.NewStatus(framework.Unschedulable, "cannot align container")
}
// subtract the resources requested by the container from the given NUMA.
// this is necessary, so we won't allocate the same resources for the upcoming containers
err := subtractResourcesFromNUMANodeList(clh, nodes, numaID, qos, container.Resources.Requests)
if err != nil {
// this is an internal error which should never happen
return framework.NewStatus(framework.Error, "inconsistent resource accounting", err.Error())
}
clh.V(4).Info("container aligned", "numaCell", numaID)
}
return nil
}