Skip to content

Commit 1ef5ed1

Browse files
committed
fix: cache util fixes
The checking functions in the cache utils had ambiguous logging entries: I0925 07:48:34.403937 5756 util.go:79] schedulerPodName is responsible to Node k3d-volcano-dev-agent-2 Since in single scheduler scenarios the schedulerPodname is not populated. These entries are intimidating, because: - It's not clear that we are in caching territory so no things to be afraid. - Looks weird that there is an empty string after schedulerPodName. Furthermore, if it's empty the consistent hash circle is not needed to be checked. Signed-off-by: Hajnal Máté <[email protected]>
1 parent ea5e83d commit 1ef5ed1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/scheduler/cache/util.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ func responsibleForPod(pod *v1.Pod, schedulerNames []string, mySchedulerPodName
4444
if !slices.Contains(schedulerNames, pod.Spec.SchedulerName) {
4545
return false
4646
}
47+
48+
if mySchedulerPodName == "" {
49+
klog.V(5).Infof("No schedulerPodName specified for pod %v (not a multi-scheduler scenario)", pod.Name)
50+
return true
51+
}
52+
4753
if c != nil {
4854
var key string
4955
if len(pod.OwnerReferences) != 0 {
@@ -66,6 +72,11 @@ func responsibleForPod(pod *v1.Pod, schedulerNames []string, mySchedulerPodName
6672

6773
// responsibleForNode returns true if the Node is assigned to current scheduler in multi-scheduler scenario
6874
func responsibleForNode(nodeName string, mySchedulerPodName string, c *consistent.Consistent) bool {
75+
if mySchedulerPodName == "" {
76+
klog.V(5).Infof("No schedulerPodName specified for Node %v (not a multi-scheduler scenario)", nodeName)
77+
return true
78+
}
79+
6980
if c != nil {
7081
schedulerPodName, err := c.Get(nodeName)
7182
if err != nil {
@@ -82,6 +93,12 @@ func responsibleForNode(nodeName string, mySchedulerPodName string, c *consisten
8293

8394
// responsibleForPodGroup returns true if Job which PodGroup belongs is assigned to current scheduler in multi-schedulers scenario
8495
func responsibleForPodGroup(pg *scheduling.PodGroup, mySchedulerPodName string, c *consistent.Consistent) bool {
96+
if mySchedulerPodName == "" {
97+
klog.V(5).Infof("No schedulerPodName specified for PodGroup %v/%v (not a multi-scheduler scenario)",
98+
pg.Namespace, pg.Name)
99+
return true
100+
}
101+
85102
if c != nil {
86103
var key string
87104
if len(pg.OwnerReferences) != 0 {

0 commit comments

Comments
 (0)