diff --git a/pkg/scheduler/frameworkext/reservation_info.go b/pkg/scheduler/frameworkext/reservation_info.go index 2eca66baf..3368bfa34 100644 --- a/pkg/scheduler/frameworkext/reservation_info.go +++ b/pkg/scheduler/frameworkext/reservation_info.go @@ -378,6 +378,9 @@ func (ri *ReservationInfo) UpdateReservation(r *schedulingv1alpha1.Reservation) if ri.Allocated != nil { ri.Allocated = quotav1.Mask(ri.Allocated, ri.ResourceNames) } + reserved := util.GetNodeReservationFromAnnotation(r.Annotations) + ri.Reserved = reserved + ownerMatchers, err := reservationutil.ParseReservationOwnerMatchers(r.Spec.Owners) if err != nil { klog.ErrorS(err, "Failed to parse reservation owner matchers", "reservation", klog.KObj(r)) @@ -407,6 +410,8 @@ func (ri *ReservationInfo) UpdatePod(pod *corev1.Pod) { ri.Pod = pod ri.AllocatablePorts = util.RequestedHostPorts(pod) ri.Allocated = quotav1.Mask(ri.Allocated, ri.ResourceNames) + reserved := util.GetNodeReservationFromAnnotation(pod.Annotations) + ri.Reserved = reserved owners, err := apiext.GetReservationOwners(pod.Annotations) if err != nil { diff --git a/pkg/scheduler/frameworkext/reservation_info_test.go b/pkg/scheduler/frameworkext/reservation_info_test.go index 93595176e..483bf8d45 100644 --- a/pkg/scheduler/frameworkext/reservation_info_test.go +++ b/pkg/scheduler/frameworkext/reservation_info_test.go @@ -483,6 +483,28 @@ func TestReservationInfoUpdateReservation(t *testing.T) { ParseError: nil, }, }, + { + name: "reservation's reserved has changed", + reservation: reservation, + newReservation: func() *schedulingv1alpha1.Reservation { + r := reservation.DeepCopy() + if r.Annotations == nil { + r.Annotations = map[string]string{} + } + r.Annotations[apiext.AnnotationNodeReservation] = `{"resources": {"cpu": "1"}}` + return r + }(), + want: &ReservationInfo{ + ResourceNames: []corev1.ResourceName{corev1.ResourceCPU, corev1.ResourceMemory}, + Allocatable: allocatable.DeepCopy(), + Reserved: map[corev1.ResourceName]resource.Quantity{ + corev1.ResourceCPU: resource.MustParse("1"), + }, + AssignedPods: map[types.UID]*PodRequirement{}, + OwnerMatchers: ownerMatchers, + ParseError: nil, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {