Skip to content

Commit

Permalink
jobflow_controller use struct as workequeue key
Browse files Browse the repository at this point in the history
  • Loading branch information
kingeasternsun committed Sep 21, 2023
1 parent 62bcf89 commit ed41c59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/controllers/jobflow/jobflow_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type jobflowcontroller struct {
recorder record.EventRecorder

queue workqueue.RateLimitingInterface
enqueueJobFlow func(req *apis.FlowRequest)
enqueueJobFlow func(req apis.FlowRequest)

syncHandler func(req *apis.FlowRequest) error

Expand Down Expand Up @@ -164,13 +164,13 @@ func (jf *jobflowcontroller) processNextWorkItem() bool {
// period.
defer jf.queue.Done(obj)

req, ok := obj.(*apis.FlowRequest)
req, ok := obj.(apis.FlowRequest)
if !ok {
klog.Errorf("%v is not a valid queue request struct.", obj)
return true
}

err := jf.syncHandler(req)
err := jf.syncHandler(&req)
jf.handleJobFlowErr(err, obj)

return true
Expand Down Expand Up @@ -218,7 +218,7 @@ func (jf *jobflowcontroller) handleJobFlowErr(err error, obj interface{}) {
return
}

req, _ := obj.(*apis.FlowRequest)
req, _ := obj.(apis.FlowRequest)
jf.recordEventsForJobFlow(req.Namespace, req.JobFlowName, v1.EventTypeWarning, string(req.Action),
fmt.Sprintf("%v JobFlow failed for %v", req.Action, err))
klog.V(4).Infof("Dropping JobFlow request %v out of the queue for %v.", obj, err)
Expand Down
10 changes: 5 additions & 5 deletions pkg/controllers/jobflow/jobflow_controller_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"volcano.sh/volcano/pkg/controllers/apis"
)

func (jf *jobflowcontroller) enqueue(req *apis.FlowRequest) {
func (jf *jobflowcontroller) enqueue(req apis.FlowRequest) {
jf.queue.Add(req)
}

Expand All @@ -36,7 +36,7 @@ func (jf *jobflowcontroller) addJobFlow(obj interface{}) {
return
}

req := &apis.FlowRequest{
req := apis.FlowRequest{
Namespace: jobFlow.Namespace,
JobFlowName: jobFlow.Name,

Expand Down Expand Up @@ -69,7 +69,7 @@ func (jf *jobflowcontroller) updateJobFlow(oldObj, newObj interface{}) {
return
}

req := &apis.FlowRequest{
req := apis.FlowRequest{
Namespace: newJobFlow.Namespace,
JobFlowName: newJobFlow.Name,

Expand Down Expand Up @@ -107,12 +107,12 @@ func (jf *jobflowcontroller) updateJob(oldObj, newObj interface{}) {
return
}

req := &apis.FlowRequest{
req := apis.FlowRequest{
Namespace: newJob.Namespace,
JobFlowName: jobFlowName,
Action: jobflowv1alpha1.SyncJobFlowAction,
Event: jobflowv1alpha1.OutOfSyncEvent,
}

jf.queue.Add(req)
jf.enqueueJobFlow(req)
}

0 comments on commit ed41c59

Please sign in to comment.