-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Improved readability for messages being logged #58061
Improved readability for messages being logged #58061
Conversation
@@ -178,7 +178,7 @@ func (cache *schedulerCache) ForgetPod(pod *v1.Pod) error { | |||
|
|||
currState, ok := cache.podStates[key] | |||
if ok && currState.pod.Spec.NodeName != pod.Spec.NodeName { | |||
return fmt.Errorf("pod %v state was assumed on a different node", key) | |||
return fmt.Errorf("pod %v was assumed on %v but is on %v", key, pod.Spec.NodeName, currState.pod.Spec.NodeName) |
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.
s/but is on/but assigned to/
@@ -241,7 +241,7 @@ func (cache *schedulerCache) AddPod(pod *v1.Pod) error { | |||
case ok && cache.assumedPods[key]: | |||
if currState.pod.Spec.NodeName != pod.Spec.NodeName { | |||
// The pod was added to a different node than it was assumed to. | |||
glog.Warningf("Pod %v assumed to a different node than added to.", key) | |||
glog.Warningf("pod %v was assumed to be on %v but got added to %v", key, pod.Spec.NodeName, currState.pod.Spec.NodeName) |
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.
start with big letter for log
@@ -277,14 +277,14 @@ func (cache *schedulerCache) UpdatePod(oldPod, newPod *v1.Pod) error { | |||
// before Update event, in which case the state would change from Assumed to Added. | |||
case ok && !cache.assumedPods[key]: | |||
if currState.pod.Spec.NodeName != newPod.Spec.NodeName { | |||
glog.Errorf("Pod %v updated on a different node than previously added to.", key) | |||
glog.Errorf("pod %v updated on a different node than previously added to.", key) |
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.
start with big letter for log
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.
Just to be clear, @k82cn, this is right, it should start with lower case?
@@ -304,7 +304,7 @@ func (cache *schedulerCache) RemovePod(pod *v1.Pod) error { | |||
// before Remove event, in which case the state would change from Assumed to Added. | |||
case ok && !cache.assumedPods[key]: | |||
if currState.pod.Spec.NodeName != pod.Spec.NodeName { | |||
glog.Errorf("Pod %v removed from a different node than previously added to.", key) | |||
glog.Errorf("pod %v was assumed to be on %v but got added to %v", key, pod.Spec.NodeName, currState.pod.Spec.NodeName) |
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 should be upper case.
@@ -313,7 +313,7 @@ func (cache *schedulerCache) RemovePod(pod *v1.Pod) error { | |||
} | |||
delete(cache.podStates, key) | |||
default: | |||
return fmt.Errorf("pod state wasn't added but get removed. Pod key: %v", key) | |||
return fmt.Errorf("pod %v wasn't added so cannot be removed", key) |
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.
Please mention cache here:
"pod %v is not found in the scheduler cache, so cannot be removed from it"
ca2f9e1
to
2b8c110
Compare
/retest |
@@ -131,7 +131,7 @@ func (cache *schedulerCache) AssumePod(pod *v1.Pod) error { | |||
cache.mu.Lock() | |||
defer cache.mu.Unlock() | |||
if _, ok := cache.podStates[key]; ok { | |||
return fmt.Errorf("pod %v state wasn't initial but get assumed", key) | |||
return fmt.Errorf("Pod %v's state wasn't initialized, so can't be assumed", key) |
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.
I would change this to "Pod %v is not found in the cache, so can't be assumed".
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.
Done @bsalamat
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.
we should not return error message started with big letter :)
2b8c110
to
ade788f
Compare
/lgtm |
golint would like 1. start with big letter for log message, and 2. start with litter letter for message of error. |
no other comments. |
@@ -345,7 +345,7 @@ func (cache *schedulerCache) GetPod(pod *v1.Pod) (*v1.Pod, error) { | |||
|
|||
podState, ok := cache.podStates[key] | |||
if !ok { | |||
return nil, fmt.Errorf("pod %v does not exist", key) | |||
return nil, fmt.Errorf("Pod %v does not exist in scheduler cache", key) |
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.
As k82cn suggested before, error message should start with lower case.
/lgtm cancel |
ade788f
to
bafda88
Compare
I think removing the package from pkg/scheduler/schedulercache out of hack/.golint_failures does solve the problem, but the package may fail golint for other reasons beyond the scope of this PR. |
bafda88
to
16ff0c2
Compare
I have updated the PR and I created an issue for golint validation in scheduler pkg. #58234 |
/lgtm Thanks a lot, @ravisantoshgudimetla for this PR and also for filing the issue to clean up golint warnings. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bsalamat, ravisantoshgudimetla Associated issue: #57152 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
This improves the readability for messages seen by end-user. /cc @jwforres @bsalamat - For UX
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #57152
Release note: