Skip to content
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

scheduler: improve gang log #2009

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

googs1025
Copy link
Contributor

Ⅰ. Describe what this PR does

I modified the current log level output method. In order to reduce log printing, I only print when --v=4 is used, and use klog.V().ErrorS for the err!=nil part.

Ⅱ. Does this pull request fix one issue?

fix: #1895 (comment)

Ⅲ. Describe how to verify it

Ⅳ. Special notes for reviews

V. Checklist

  • I have written necessary docs and comments
  • I have added necessary unit tests and integration tests
  • All checks passed in make test

Signed-off-by: googs1025 <googs1025@gmail.com>
@koordinator-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign eahydra after the PR has been reviewed.
You can assign the PR to them by writing /assign @eahydra in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.67%. Comparing base (c8bfd9e) to head (746d6bd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2009      +/-   ##
==========================================
+ Coverage   68.65%   68.67%   +0.01%     
==========================================
  Files         421      421              
  Lines       38916    38916              
==========================================
+ Hits        26719    26726       +7     
+ Misses       9880     9872       -8     
- Partials     2317     2318       +1     
Flag Coverage Δ
unittests 68.67% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@googs1025
Copy link
Contributor Author

@buptcozy @eahydra /PTAL

@hormes
Copy link
Member

hormes commented Apr 28, 2024

Why do we need to downgrade error logs to V4?

@googs1025
Copy link
Contributor Author

Why do we need to downgrade error logs to V4?

Indeed, this level needs to be confirmed. However, setting the log level can effectively reduce the number of log prints.

@@ -145,7 +146,7 @@ func (gang *Gang) tryInitByPodConfig(pod *v1.Pod, args *config.CoschedulingArgs)
matchPolicy := util.GetGangMatchPolicyByPod(pod)
if matchPolicy != extension.GangMatchPolicyOnlyWaiting && matchPolicy != extension.GangMatchPolicyWaitingAndRunning &&
matchPolicy != extension.GangMatchPolicyOnceSatisfied {
klog.Errorf("pod's annotation AnnotationGangMatchPolicy illegal, gangName: %v, value: %v",
klog.V(4).Infof("pod's annotation AnnotationGangMatchPolicy illegal, gangName: %v, value: %v",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should determine if matchPolicy is an empty string and if not, log an error.

Comment on lines 125 to 136
totalChildrenNum, err := strconv.ParseInt(pod.Annotations[extension.AnnotationGangTotalNum], 10, 32)
if err != nil {
klog.Errorf("pod's annotation totalNumber illegal, gangName: %v, value: %v",
klog.V(4).ErrorS(err, "pod's annotation totalNumber illegal, gangName: %v, value: %v",
gang.Name, pod.Annotations[extension.AnnotationGangTotalNum])
totalChildrenNum = int64(minRequiredNumber)
} else if totalChildrenNum != 0 && totalChildrenNum < int64(minRequiredNumber) {
klog.Errorf("pod's annotation totalNumber cannot less than minRequiredNumber, gangName: %v, totalNumber: %v,minRequiredNumber: %v",

klog.V(4).Infof("pod's annotation totalNumber cannot less than minRequiredNumber, gangName: %v, totalNumber: %v,minRequiredNumber: %v",
gang.Name, pod.Annotations[extension.AnnotationGangTotalNum], minRequiredNumber)
totalChildrenNum = int64(minRequiredNumber)
}
gang.TotalChildrenNum = int(totalChildrenNum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We encourage cleaner code, which of course includes improved logging.

Suggested change
totalChildrenNum, err := strconv.ParseInt(pod.Annotations[extension.AnnotationGangTotalNum], 10, 32)
if err != nil {
klog.Errorf("pod's annotation totalNumber illegal, gangName: %v, value: %v",
klog.V(4).ErrorS(err, "pod's annotation totalNumber illegal, gangName: %v, value: %v",
gang.Name, pod.Annotations[extension.AnnotationGangTotalNum])
totalChildrenNum = int64(minRequiredNumber)
} else if totalChildrenNum != 0 && totalChildrenNum < int64(minRequiredNumber) {
klog.Errorf("pod's annotation totalNumber cannot less than minRequiredNumber, gangName: %v, totalNumber: %v,minRequiredNumber: %v",
klog.V(4).Infof("pod's annotation totalNumber cannot less than minRequiredNumber, gangName: %v, totalNumber: %v,minRequiredNumber: %v",
gang.Name, pod.Annotations[extension.AnnotationGangTotalNum], minRequiredNumber)
totalChildrenNum = int64(minRequiredNumber)
}
gang.TotalChildrenNum = int(totalChildrenNum)
var expectedTotalNum int64
s := pod.Annotations[extension.AnnotationGangTotalNum]
if s != "" {
var err error
expectedTotalNum, err = strconv.ParseInt(s)
if err != nil {
klog.V(4).ErrorS(err, "illegal annotation", "key", extension.AnnotationGangTotalNum, "value": s)
}
}
if expectedTotalNum < int64(minRequiredNumber) {
expectedTotalNum = int64(minRequiredNumber)
}
gang.TotalChildrenNum = int(expectedTotalNum)

@@ -157,15 +158,15 @@ func (gang *Gang) tryInitByPodConfig(pod *v1.Pod, args *config.CoschedulingArgs)

waitTime, err := time.ParseDuration(pod.Annotations[extension.AnnotationGangWaitTime])
if err != nil || waitTime <= 0 {
klog.Errorf("pod's annotation GangWaitTimeAnnotation illegal, gangName: %v, value: %v",
klog.V(4).ErrorS(err, "pod's annotation GangWaitTimeAnnotation illegal, gangName: %v, value: %v",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these logs have same problems, should improve these codes to make more clean.

@eahydra eahydra changed the title fix: fix gang log level scheduler: improve gang log May 7, 2024
@jasonliu747
Copy link
Member

/assign @ZiMengSheng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[proposal] improve coscheduling's log
5 participants