-
Notifications
You must be signed in to change notification settings - Fork 994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean code #92
Clean code #92
Conversation
AddFunc: cc.addCommand, | ||
}, | ||
cc.cmdInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | ||
AddFunc: cc.addCommand, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the ControllerdBy
filter logic here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any command resource not managed by volcano?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No for now.
DeleteFunc: cc.deletePod, | ||
}, | ||
podInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | ||
AddFunc: cc.addPod, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed, we already have many other checks in event handlers, like this
taskName, found := pod.Annotations[vkbatchv1.TaskSpecKey]
if !found {
glog.Infof("Failed to find taskName of Pod <%s/%s>, skipping",
pod.Namespace, pod.Name)
return
}
jobName, found := pod.Annotations[vkbatchv1.JobNameKey]
if !found {
glog.Infof("Failed to find jobName of Pod <%s/%s>, skipping",
pod.Namespace, pod.Name)
return
}
version, found := pod.Annotations[vkbatchv1.JobVersion]
if !found {
glog.Infof("Failed to find jobVersion of Pod <%s/%s>, skipping",
pod.Namespace, pod.Name)
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is faster, just asking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above check is inevitable, so it's enough, if we check twice, then absolutely double time wasting
errs = append(errs, err) | ||
continue | ||
} | ||
if err := cc.deleteJobPod(job.Name, pod); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err == nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
/lgtm |
Continue removing some redundant code