Skip to content

Commit

Permalink
controllers: update queue cache immediately instead of re-enqueuing t…
Browse files Browse the repository at this point in the history
…he request

Signed-off-by: sceneryback <afterbreeze@hotmail.com>
  • Loading branch information
sceneryback committed Sep 24, 2024
1 parent e263ff7 commit 1f1ffc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
29 changes: 8 additions & 21 deletions pkg/controllers/queue/queue_controller_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,10 @@ import (
"k8s.io/klog/v2"

"volcano.sh/apis/pkg/apis/bus/v1alpha1"
busv1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1"
schedulingv1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
"volcano.sh/volcano/pkg/controllers/apis"
"volcano.sh/volcano/pkg/controllers/queue/state"
)

func (c *queuecontroller) handleNotFoundPodGroup(queue, key string) {
c.pgMutex.Lock()
defer c.pgMutex.Unlock()

delete(c.podGroups[queue], key)

req := &apis.Request{
QueueName: queue,

Event: busv1alpha1.OutOfSyncEvent,
Action: busv1alpha1.SyncQueueAction,
}

c.enqueue(req)
}

func (c *queuecontroller) syncQueue(queue *schedulingv1beta1.Queue, updateStateFn state.UpdateQueueStatusFn) error {
klog.V(4).Infof("Begin to sync queue %s.", queue.Name)
defer klog.V(4).Infof("End sync queue %s.", queue.Name)
Expand All @@ -63,10 +45,15 @@ func (c *queuecontroller) syncQueue(queue *schedulingv1beta1.Queue, updateStateF

pg, err := c.pgLister.PodGroups(ns).Get(name)
if err != nil {
if errors.IsNotFound(err) {
c.handleNotFoundPodGroup(queue.Name, pgKey)
if !errors.IsNotFound(err) {
return err
}
return err

klog.V(4).Infof("sync local cache since podGroup %s not found.", pgKey)
c.pgMutex.Lock()
delete(c.podGroups[queue.Name], pgKey)
c.pgMutex.Unlock()
continue
}

switch pg.Status.Phase {
Expand Down
4 changes: 0 additions & 4 deletions pkg/controllers/queue/queue_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,6 @@ func TestSyncQueue(t *testing.T) {

err := c.syncQueue(testcase.queue, nil)

if len(testcase.delayDeletedPodGroups) > 0 {
c.processNextWorkItem()
}

item, _ := c.vcClient.SchedulingV1beta1().Queues().Get(context.TODO(), testcase.queue.Name, metav1.GetOptions{})
if err != nil && !reflect.DeepEqual(testcase.ExpectStatus, item.Status) {
t.Errorf("case %d (%s): expected: %v, got %v ", i, testcase.Name, testcase.ExpectStatus, item.Status)
Expand Down

0 comments on commit 1f1ffc8

Please sign in to comment.