mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #117588 from kerthcet/cleanup/use-genericset
Avoid duplicated dots in pod status when preempting
This commit is contained in:
commit
029d518970
@ -97,8 +97,9 @@ func (pl *DefaultPreemption) PostFilter(ctx context.Context, state *framework.Cy
|
||||
}
|
||||
|
||||
result, status := pe.Preempt(ctx, pod, m)
|
||||
if status.Message() != "" {
|
||||
return result, framework.NewStatus(status.Code(), "preemption: "+status.Message())
|
||||
msg := status.Message()
|
||||
if len(msg) > 0 {
|
||||
return result, framework.NewStatus(status.Code(), "preemption: "+msg)
|
||||
}
|
||||
return result, status
|
||||
}
|
||||
|
@ -307,8 +307,6 @@ type FitError struct {
|
||||
const (
|
||||
// NoNodeAvailableMsg is used to format message when no nodes available.
|
||||
NoNodeAvailableMsg = "0/%v nodes are available"
|
||||
// SeparatorFormat is used to separate PreFilterMsg, FilterMsg and PostFilterMsg.
|
||||
SeparatorFormat = " %v."
|
||||
)
|
||||
|
||||
// Error returns detailed information of why the pod failed to fit on each node.
|
||||
@ -319,7 +317,7 @@ func (f *FitError) Error() string {
|
||||
if preFilterMsg != "" {
|
||||
// PreFilter plugin returns unschedulable.
|
||||
// Add the messages from PreFilter plugins to reasonMsg.
|
||||
reasonMsg += fmt.Sprintf(SeparatorFormat, preFilterMsg)
|
||||
reasonMsg += fmt.Sprintf(" %v.", preFilterMsg)
|
||||
}
|
||||
|
||||
if preFilterMsg == "" {
|
||||
@ -346,7 +344,7 @@ func (f *FitError) Error() string {
|
||||
}
|
||||
sortedFilterMsg := sortReasonsHistogram()
|
||||
if len(sortedFilterMsg) != 0 {
|
||||
reasonMsg += fmt.Sprintf(SeparatorFormat, strings.Join(sortedFilterMsg, ", "))
|
||||
reasonMsg += fmt.Sprintf(" %v.", strings.Join(sortedFilterMsg, ", "))
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,9 +353,8 @@ func (f *FitError) Error() string {
|
||||
// since we may run PostFilter (if enabled) in both cases.
|
||||
postFilterMsg := f.Diagnosis.PostFilterMsg
|
||||
if postFilterMsg != "" {
|
||||
reasonMsg += fmt.Sprintf(SeparatorFormat, postFilterMsg)
|
||||
reasonMsg += fmt.Sprintf(" %v", postFilterMsg)
|
||||
}
|
||||
|
||||
return reasonMsg
|
||||
}
|
||||
|
||||
|
@ -1415,7 +1415,7 @@ func TestFitError_Error(t *testing.T) {
|
||||
// PostFilterMsg will be included.
|
||||
PostFilterMsg: "Error running PostFilter plugin FailedPostFilter",
|
||||
},
|
||||
wantReasonMsg: "0/3 nodes are available: Node(s) failed PreFilter plugin FalsePreFilter. Error running PostFilter plugin FailedPostFilter.",
|
||||
wantReasonMsg: "0/3 nodes are available: Node(s) failed PreFilter plugin FalsePreFilter. Error running PostFilter plugin FailedPostFilter",
|
||||
},
|
||||
{
|
||||
name: "nodes failed one Filter plugin with an empty PostFilterMsg",
|
||||
@ -1442,7 +1442,7 @@ func TestFitError_Error(t *testing.T) {
|
||||
},
|
||||
PostFilterMsg: "Error running PostFilter plugin FailedPostFilter",
|
||||
},
|
||||
wantReasonMsg: "0/3 nodes are available: 3 Node(s) failed Filter plugin FalseFilter-1. Error running PostFilter plugin FailedPostFilter.",
|
||||
wantReasonMsg: "0/3 nodes are available: 3 Node(s) failed Filter plugin FalseFilter-1. Error running PostFilter plugin FailedPostFilter",
|
||||
},
|
||||
{
|
||||
name: "nodes failed two Filter plugins with an empty PostFilterMsg",
|
||||
@ -1469,7 +1469,7 @@ func TestFitError_Error(t *testing.T) {
|
||||
},
|
||||
PostFilterMsg: "Error running PostFilter plugin FailedPostFilter",
|
||||
},
|
||||
wantReasonMsg: "0/3 nodes are available: 1 Node(s) failed Filter plugin FalseFilter-2, 2 Node(s) failed Filter plugin FalseFilter-1. Error running PostFilter plugin FailedPostFilter.",
|
||||
wantReasonMsg: "0/3 nodes are available: 1 Node(s) failed Filter plugin FalseFilter-2, 2 Node(s) failed Filter plugin FalseFilter-1. Error running PostFilter plugin FailedPostFilter",
|
||||
},
|
||||
{
|
||||
name: "failed to Permit on node",
|
||||
|
Loading…
Reference in New Issue
Block a user