in pkg/sysched/sysched.go [231:275]
func (sc *SySched) Score(ctx context.Context, cs *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {
// Read directly from API server because cached state in SnapSharedLister not always up-to-date
// especially during initial scheduler start.
node, err := sc.handle.ClientSet().CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
if err != nil {
return 0, nil
}
podSyscalls := sc.getSyscalls(pod)
// NOTE: this condition is true only when a pod does not
// have a syscall profile, or the unconfined syscall is
// not set. We return a large number (INT64_MAX) as score.
if len(podSyscalls) == 0 {
return math.MaxInt64, nil
}
_, hostSyscalls := sc.getHostSyscalls(node.Name)
// when a host or node does not have any pods
// running, the extraneous syscall score is zero
if hostSyscalls == nil {
return 0, nil
}
diffSyscalls := hostSyscalls.Difference(podSyscalls)
totalDiffs := sc.calcScore(diffSyscalls)
// add the difference existing pods will see if new Pod is added into this host
newHostSyscalls := hostSyscalls.Clone()
newHostSyscalls = newHostSyscalls.Union(podSyscalls)
for _, p := range sc.HostToPods[node.Name] {
podSyscalls = sc.getSyscalls(p)
diffSyscalls = newHostSyscalls.Difference(podSyscalls)
totalDiffs += sc.calcScore(diffSyscalls)
}
sc.ExSAvg = sc.ExSAvg + (float64(totalDiffs)-sc.ExSAvg)/float64(sc.ExSAvgCount)
sc.ExSAvgCount += 1
klog.V(10).Info("ExSAvg: ", sc.ExSAvg)
klog.V(10).InfoS("Score: ", "totalDiffs", totalDiffs, "pod", pod.Name, "node", nodeName)
return int64(totalDiffs), nil
}