Skip to content

Commit 9ba0584

Browse files
authored
Fixed reconcile trigger mapping function: allocation to solver (#5) (#124)
1 parent 2fba5cf commit 9ba0584

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pkg/rear-manager/solver_controller.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,22 @@ func (r *SolverReconciler) reservationToSolver(_ context.Context, o client.Objec
871871
}
872872

873873
func (r *SolverReconciler) allocationToSolver(_ context.Context, o client.Object) []reconcile.Request {
874-
solverName := o.(*nodecorev1alpha1.Allocation).Spec.Contract.Name
874+
var solverName string
875+
contractName := o.(*nodecorev1alpha1.Allocation).Spec.Contract.Name
876+
// Get the reservation with status.Contract.Name == solverName
877+
reservationList := &reservationv1alpha1.ReservationList{}
878+
if err := r.Client.List(context.Background(), reservationList); err != nil {
879+
klog.Errorf("Error when listing Reservations: %s", err)
880+
return nil
881+
}
882+
883+
for i := range reservationList.Items {
884+
if reservationList.Items[i].Status.Contract.Name == contractName {
885+
solverName = reservationList.Items[i].Spec.SolverID
886+
break
887+
}
888+
}
889+
875890
return []reconcile.Request{
876891
{
877892
NamespacedName: types.NamespacedName{

0 commit comments

Comments
 (0)