Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koord-scheduler: Pod updates should not update the timestamp #2100

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
koord-scheduler: Pod updates should not update the timestamp
Signed-off-by: zwForrest <756495135@qq.com>
  • Loading branch information
zwForrest committed Jun 13, 2024
commit ec12c097f46374533d50419a7a798e41edb9fa4e
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 {
zwForrest marked this conversation as resolved.
Show resolved Hide resolved
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