mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Merge pull request #79578 from cezarsa/stable-node-images
kubelet: ensure stable order for images in node status
This commit is contained in:
		| @@ -53,6 +53,9 @@ func (s PodsByCreationTime) Less(i, j int) bool { | ||||
| type ByImageSize []kubecontainer.Image | ||||
|  | ||||
| func (a ByImageSize) Less(i, j int) bool { | ||||
| 	if a[i].Size == a[j].Size { | ||||
| 		return a[i].ID > a[j].ID | ||||
| 	} | ||||
| 	return a[i].Size > a[j].Size | ||||
| } | ||||
| func (a ByImageSize) Len() int      { return len(a) } | ||||
|   | ||||
| @@ -160,6 +160,12 @@ func buildByImageSize() ByImageSize { | ||||
| 			RepoDigests: []string{"foo-rd31", "foo-rd32"}, | ||||
| 			Size:        3, | ||||
| 		}, | ||||
| 		{ | ||||
| 			ID:          "4", | ||||
| 			RepoTags:    []string{"foo-tag41", "foo-tag42"}, | ||||
| 			RepoDigests: []string{"foo-rd41", "foo-rd42"}, | ||||
| 			Size:        3, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -169,7 +175,7 @@ func TestByImageSizeLen(t *testing.T) { | ||||
| 		el     int | ||||
| 	}{ | ||||
| 		{[]kubecontainer.Image{}, 0}, | ||||
| 		{buildByImageSize(), 3}, | ||||
| 		{buildByImageSize(), 4}, | ||||
| 		{nil, 0}, | ||||
| 	} | ||||
|  | ||||
| @@ -211,6 +217,7 @@ func TestByImageSizeLess(t *testing.T) { | ||||
| 		// descending order | ||||
| 		{buildByImageSize(), 0, 2, false}, | ||||
| 		{buildByImageSize(), 1, 0, true}, | ||||
| 		{buildByImageSize(), 3, 2, true}, | ||||
| 	} | ||||
|  | ||||
| 	for _, fooTest := range fooTests { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot