Skip to content

Commit

Permalink
koord-scheduler: Pod updates should not update the timestamp (#2100)
Browse files Browse the repository at this point in the history
Signed-off-by: zwForrest <756495135@qq.com>
  • Loading branch information
zwForrest committed Jun 14, 2024
1 parent 4c143e6 commit ae25a92
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/scheduler/plugins/loadaware/pod_assign_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ func (p *podAssignCache) assign(nodeName string, pod *corev1.Pod) {
m = make(map[types.UID]*podAssignInfo)
p.podInfoItems[nodeName] = m
}
m[pod.UID] = &podAssignInfo{
timestamp: timeNowFn(),
pod: pod,

if _, ok := m[pod.UID]; ok {
m[pod.UID].pod = pod
} else {
m[pod.UID] = &podAssignInfo{
timestamp: timeNowFn(),
pod: pod,
}
}
}

Expand Down
58 changes: 58 additions & 0 deletions pkg/scheduler/plugins/loadaware/pod_assign_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,64 @@ func TestPodAssignCache_OnUpdate(t *testing.T) {
},
},
},
{
name: "update scheduled running pod, timestamp won't be updated",
pod: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "123456789",
Namespace: "default",
Name: "test",
},
Spec: corev1.PodSpec{
NodeName: "test-node",
},
Status: corev1.PodStatus{
Phase: corev1.PodRunning,
},
},
assignCache: &podAssignCache{
podInfoItems: map[string]map[types.UID]*podAssignInfo{
"test-node": {
"123456789": &podAssignInfo{
pod: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "123456789",
Namespace: "default",
Name: "test",
},
Spec: corev1.PodSpec{
NodeName: "test-node",
},
Status: corev1.PodStatus{
Phase: corev1.PodRunning,
},
},
timestamp: fakeTimeNowFn().Add(1000),
},
},
},
},
wantCache: map[string]map[types.UID]*podAssignInfo{
"test-node": {
"123456789": &podAssignInfo{
pod: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "123456789",
Namespace: "default",
Name: "test",
},
Spec: corev1.PodSpec{
NodeName: "test-node",
},
Status: corev1.PodStatus{
Phase: corev1.PodRunning,
},
},
timestamp: fakeTimeNowFn().Add(1000),
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit ae25a92

Please sign in to comment.