Repository: kubernetes
Issue: scheduler: ```ImageLocality``` gives nodes in different situation the same score
Labels: kind/bug,sig/scheduling,lifecycle/stale,needs-triage

### What happened?

I managed to reproduce [a bug that went stale](https://github.com/kubernetes/kubernetes/issues/112573) on the latest main branch. And also noticed a new situation that may trigger the bug.

The ```ImageLocality``` plugin may give a same score to nodes in different situations.

The related code:
```go
imageScores := sumImageScores(nodeInfo, pod, totalNumNodes, logger, nodeName)
score := calculatePriority(imageScores, len(pod.Spec.InitContainers)+len(pod.Spec.Containers), logger)

func calculatePriority(sumScores int64, numContainers int, logger klog.Logger) int64 {
	maxThreshold := maxContainerThreshold * int64(numContainers)
	if sumScores < minThreshold {
		sumScores = minThreshold
	} else if sumScores > maxThreshold {
		sumScores = maxThreshold
	}
	return framework.MaxNodeScore * (sumScores - minThreshold) / (maxThreshold - minThreshold)
}
```

**This will happen when the a node has a fully pulled image that is relatively small, another doesn't** (But still need time to pull, in this case image size is about 70MB). 

The node with fully pulled image has an original ```sumScores``` too close to ```minThreshold```, and the other node without that image has an original ```sumScores``` = 0. So after clip the difference of two nodes' ```sumScores``` is relatively small compared to ```maxThreshold - minThreshold```. 

Then the plugin calculate the score, and this will happen: For the first node's score ```= 100 * 0.0001 = 0```, for the second node' score ```= 100 * 0 = 0```. Resulting the same score even if the first node has fully pulled this image (about 70MB) and the second node hasn't.

---

**And I think this will also happen when a node has many relatively large image, another doesn't (the second also has some image but not as large as the first one).** Then the first node's ```sumScores``` is far more beyond ```maxThreshold```, and the second node's ```sumScores``` is just a little bit smaller than ```maxThreshold```. After clipping, the first node's ```sumScores```  becomes ```maxThreshold```.

Then the plugin calculate the score, and this will happen: For the first node's score ```= 100 * 1 = 100```, for the second node' score ```= 100 * 0.999 = 100```. Resulting the same score even if the first node has far more image than the second node.

### What did you expect to happen?

ImageLocality gives two nodes a different score.

### How can we reproduce it (as minimally and precisely as possible)?

I first create two nodes (worker1 with fully pulled image, and worker2 just start pulling), then apply a pod using the following specification. 
```yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod3
spec:
  containers:
    - name: test-container
      image: gke.gcr.io/calico/cni:v3.23.1-gke.0
```

and here is the log (added some log to see what happened in image_locality):
```bash
[image_locality.go:68] "ImageScores" logger="Score.ImageLocality" pod="default/nginx3" node="kind-worker" imageScores=25531886
[image_locality.go:93] "calculatePriority" logger="Score.ImageLocality" pod="default/nginx3" node="kind-worker" minThreshold=24117248 maxThreshold=1048576000 framework.MaxNodeScore=100
[image_locality.go:68] "ImageScores" logger="Score.ImageLocality" pod="default/nginx3" node="kind-worker2" imageScores=0
[image_locality.go:93] "calculatePriority" logger="Score.ImageLocality" pod="default/nginx3" node="kind-worker2" minThreshold=24117248 maxThreshold=1048576000 framework.MaxNodeScore=100
[image_locality.go:112] ImageName="gke.gcr.io/calico/cni:v3.23.1-gke.0" Size="76595659" node="kind-worker"
...
[schedule_one.go:784] "Plugin scored node for pod" pod="default/nginx3" plugin="ImageLocality" node="kind-worker" score=0
...
[schedule_one.go:784] "Plugin scored node for pod" pod="default/nginx3" plugin="ImageLocality" node="kind-worker2" score=0
[schedule_one.go:851] "Calculated node's final score for pod" pod="default/nginx3" node="kind-worker" score=492
[schedule_one.go:851] "Calculated node's final score for pod" pod="default/nginx3" node="kind-worker2" score=492
```


### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
# paste output here
```
Client Version: v1.29.1
Server Version: v1.30.0-

Actually this is reproduced on the latest main branch.
</details>


### Cloud provider

<details>

</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```

</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>