func (s *Scheduler) admit(ctx context.Context, e *entry) error {
	log := ctrl.LoggerFrom(ctx)
	newWorkload := e.Obj.DeepCopy()
	admission := &kueue.Admission{
		ClusterQueue:  kueue.ClusterQueueReference(e.ClusterQueue),
		PodSetFlavors: make([]kueue.PodSetFlavors, len(e.TotalRequests)),
	}
	for i := range e.TotalRequests {
		admission.PodSetFlavors[i] = kueue.PodSetFlavors{
			Name:            e.Obj.Spec.PodSets[i].Name,
			ResourceFlavors: e.TotalRequests[i].Flavors,
		}
	}
	newWorkload.Spec.Admission = admission
	if err := s.cache.AssumeWorkload(newWorkload); err != nil {
		return err
	}
	log.V(2).Info("Workload assumed in the cache")

	s.admissionRoutineWrapper.Run(func() {
		err := s.client.Update(ctx, newWorkload)
		if err == nil {
			s.recorder.Eventf(newWorkload, corev1.EventTypeNormal, "Admitted", "Admitted by ClusterQueue %v", admission.ClusterQueue)
			log.V(2).Info("Workload successfully admitted and assigned flavors")
			return
		}
		// Ignore errors because the workload or clusterQueue could have been deleted
		// by an event.
		_ = s.cache.ForgetWorkload(newWorkload)
		if errors.IsNotFound(err) {
			log.V(2).Info("Workload not admitted because it was deleted")
			return
		}
		log.Error(err, "Admitting workload and assigning flavors")
		log.V(2).Info("Re-queueing")
		s.queues.RequeueWorkload(ctx, &e.Info)
	})

	return nil
}
// admit sets the admitting clusterQueue and flavors into the workload of
// the entry, and asynchronously updates the object in the apiserver after
// assuming it in the cache.
admit sets the admitting clusterQueue and flavors into the workload of
the entry, and asynchronously updates the object in the apiserver after
assuming it in the cache.
// admit sets the admitting clusterQueue and flavors into the workload of // the entry and asynchronously updates the object in the apiserver after // assuming it in the cache .
func (s *Scheduler) admit(ctx context.Context, e *entry) error {
	log := ctrl.LoggerFrom(ctx)
	newWorkload := e.Obj.DeepCopy()
	admission := &kueue.Admission{
		ClusterQueue:  kueue.ClusterQueueReference(e.ClusterQueue),
		PodSetFlavors: make([]kueue.PodSetFlavors, len(e.TotalRequests)),
	}
	for i := range e.TotalRequests {
		admission.PodSetFlavors[i] = kueue.PodSetFlavors{
			Name:            e.Obj.Spec.PodSets[i].Name,
			ResourceFlavors: e.TotalRequests[i].Flavors,
		}
	}
	newWorkload.Spec.Admission = admission
	if err := s.cache.AssumeWorkload(newWorkload); err != nil {
		return err
	}
	log.V(2).Info("Workload assumed in the cache")
	s.admissionRoutineWrapper.Run(func() {
		err := s.client.Update(ctx, newWorkload)
		if err == nil {
			s.recorder.Eventf(newWorkload, corev1.EventTypeNormal, "Admitted", "Admitted by ClusterQueue %v", admission.ClusterQueue)
			log.V(2).Info("Workload successfully admitted and assigned flavors")
			return
		}
		_ = s.cache.ForgetWorkload(newWorkload)
		if errors.IsNotFound(err) {
			log.V(2).Info("Workload not admitted because it was deleted")
			return
		}
		log.Error(err, "Admitting workload and assigning flavors")
		log.V(2).Info("Re-queueing")
		s.queues.RequeueWorkload(ctx, &e.Info)
	})
	return nil
}
func ( s * Scheduler ) admit ( ctx context . Context , e * entry ) error { log := ctrl . LoggerFrom ( ctx ) newWorkload := e . Obj . DeepCopy ( ) admission := & kueue . Admission { ClusterQueue : kueue . ClusterQueueReference ( e . ClusterQueue ) , PodSetFlavors : make ( [ ] kueue . PodSetFlavors , len ( e . TotalRequests ) ) , } for i := range e . TotalRequests { admission . PodSetFlavors [ i ] = kueue . PodSetFlavors { Name : e . Obj . Spec . PodSets [ i ] . Name , ResourceFlavors : e . TotalRequests [ i ] . Flavors , } } newWorkload . Spec . Admission = admission if err := s . cache . AssumeWorkload ( newWorkload ) ; err != nil { return err } log . V ( 2 ) . Info ( " " ) s . admissionRoutineWrapper . Run ( func ( ) { err := s . client . Update ( ctx , newWorkload ) if err == nil { s . recorder . Eventf ( newWorkload , corev1 . EventTypeNormal , " " , " " , admission . ClusterQueue ) log . V ( 2 ) . Info ( " " ) return } _ = s . cache . ForgetWorkload ( newWorkload ) if errors . IsNotFound ( err ) { log . V ( 2 ) . Info ( " " ) return } log . Error ( err , " " ) log . V ( 2 ) . Info ( " " ) s . queues . RequeueWorkload ( ctx , & e . Info ) } ) return nil }
admit sets the admitting clusterQueue and flavors into the workload of
the entry, and asynchronously updates the object in the apiserver after
assuming it in the cache.
admit sets the admitting clusterQueue and flavors into the workload of the entry and asynchronously updates the object in the apiserver after assuming it in the cache .
// Ignore errors because the workload or clusterQueue could have been deleted // by an event.