Skip to content

Commit

Permalink
scheduler: make ReservationInfo.AddAssignedPod idempotent (koordinato…
Browse files Browse the repository at this point in the history
…r-sh#1709)

Signed-off-by: Joseph <joseph.t.lee@outlook.com>
  • Loading branch information
eahydra authored and 刘硕 committed Mar 25, 2024
1 parent 2fcaad8 commit ae3ea2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/scheduler/frameworkext/helper/forcesync_eventhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apimachinerytypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
)

type forceSyncEventHandler struct {
Expand Down Expand Up @@ -64,6 +65,7 @@ func (h *forceSyncEventHandler) OnAdd(obj interface{}) {
return
}
delete(h.objects, objectUID)
klog.Warningf("Object %q has been updated multiple times in a short period of time", klog.KObj(objectMeta).String())
}
}
if h.handler != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/scheduler/frameworkext/reservation_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ func (ri *ReservationInfo) UpdatePod(pod *corev1.Pod) {
}

func (ri *ReservationInfo) AddAssignedPod(pod *corev1.Pod) {
if _, ok := ri.AssignedPods[pod.UID]; ok {
klog.Warningf("Repeatedly add assigned Pod %v in reservation %v, skip it.", klog.KObj(pod), klog.KObj(ri))
return
}
requirement := NewPodRequirement(pod)
ri.Allocated = quotav1.Add(ri.Allocated, quotav1.Mask(requirement.Requests, ri.ResourceNames))
ri.AllocatedPorts = util.AppendHostPorts(ri.AllocatedPorts, requirement.Ports)
Expand Down

0 comments on commit ae3ea2f

Please sign in to comment.