const mb … const minThreshold … const maxContainerThreshold … type ImageLocality … var _ … const Name … // Name returns name of the plugin. It is used in logs, etc. func (pl *ImageLocality) Name() string { … } // Score invoked at the score extension point. func (pl *ImageLocality) Score(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) { … } // ScoreExtensions of the Score plugin. func (pl *ImageLocality) ScoreExtensions() framework.ScoreExtensions { … } // New initializes a new plugin and returns it. func New(_ context.Context, _ runtime.Object, h framework.Handle) (framework.Plugin, error) { … } // calculatePriority returns the priority of a node. Given the sumScores of requested images on the node, the node's // priority is obtained by scaling the maximum priority value with a ratio proportional to the sumScores. func calculatePriority(sumScores int64, numContainers int) int64 { … } // sumImageScores returns the sum of image scores of all the containers that are already on the node. // Each image receives a raw score of its size, scaled by scaledImageScore. The raw scores are later used to calculate // the final score. func sumImageScores(nodeInfo *framework.NodeInfo, pod *v1.Pod, totalNumNodes int) int64 { … } // scaledImageScore returns an adaptively scaled score for the given state of an image. // The size of the image is used as the base score, scaled by a factor which considers how much nodes the image has "spread" to. // This heuristic aims to mitigate the undesirable "node heating problem", i.e., pods get assigned to the same or // a few nodes due to image locality. func scaledImageScore(imageState *framework.ImageStateSummary, totalNumNodes int) int64 { … } // normalizedImageName returns the CRI compliant name for a given image. // TODO: cover the corner cases of missed matches, e.g, // 1. Using Docker as runtime and docker.io/library/test:tag in pod spec, but only test:tag will present in node status // 2. Using the implicit registry, i.e., test:tag or library/test:tag in pod spec but only docker.io/library/test:tag // in node status; note that if users consistently use one registry format, this should not happen. func normalizedImageName(name string) string { … }