mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +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:
commit
46e58df837
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user