mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Wrap all errors in pkg/scheduler
This commit is contained in:
parent
b418bc83db
commit
f82e3c430c
@ -185,7 +185,7 @@ func (pl *falseMapPlugin) Name() string {
|
||||
}
|
||||
|
||||
func (pl *falseMapPlugin) Score(_ context.Context, _ *framework.CycleState, _ *v1.Pod, _ string) (int64, *framework.Status) {
|
||||
return 0, framework.NewStatus(framework.Error, errPrioritize.Error())
|
||||
return 0, framework.AsStatus(errPrioritize)
|
||||
}
|
||||
|
||||
func (pl *falseMapPlugin) ScoreExtensions() framework.ScoreExtensions {
|
||||
|
@ -195,7 +195,7 @@ func getPreFilterState(cycleState *framework.CycleState) (*preFilterState, error
|
||||
func (f *Fit) Filter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status {
|
||||
s, err := getPreFilterState(cycleState)
|
||||
if err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
|
||||
insufficientResources := fitsRequest(s, nodeInfo, f.ignoredResources, f.ignoredResourceGroups)
|
||||
|
@ -47,7 +47,7 @@ func (la *LeastAllocated) Name() string {
|
||||
func (la *LeastAllocated) Score(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {
|
||||
nodeInfo, err := la.handle.SnapshotSharedLister().NodeInfos().Get(nodeName)
|
||||
if err != nil {
|
||||
return 0, framework.NewStatus(framework.Error, fmt.Sprintf("getting node %q from Snapshot: %v", nodeName, err))
|
||||
return 0, framework.AsStatus(fmt.Errorf("getting node %q from Snapshot: %w", nodeName, err))
|
||||
}
|
||||
|
||||
// la.score favors nodes with fewer requested resources.
|
||||
|
@ -46,8 +46,8 @@ func (ma *MostAllocated) Name() string {
|
||||
// Score invoked at the Score extension point.
|
||||
func (ma *MostAllocated) Score(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {
|
||||
nodeInfo, err := ma.handle.SnapshotSharedLister().NodeInfos().Get(nodeName)
|
||||
if err != nil || nodeInfo.Node() == nil {
|
||||
return 0, framework.NewStatus(framework.Error, fmt.Sprintf("getting node %q from Snapshot: %v, node is nil: %v", nodeName, err, nodeInfo.Node() == nil))
|
||||
if err != nil {
|
||||
return 0, framework.AsStatus(fmt.Errorf("getting node %q from Snapshot: %w", nodeName, err))
|
||||
}
|
||||
|
||||
// ma.score favors nodes with most requested resources.
|
||||
|
@ -111,7 +111,7 @@ func (pl *RequestedToCapacityRatio) Name() string {
|
||||
func (pl *RequestedToCapacityRatio) Score(ctx context.Context, _ *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {
|
||||
nodeInfo, err := pl.handle.SnapshotSharedLister().NodeInfos().Get(nodeName)
|
||||
if err != nil {
|
||||
return 0, framework.NewStatus(framework.Error, fmt.Sprintf("getting node %q from Snapshot: %v", nodeName, err))
|
||||
return 0, framework.AsStatus(fmt.Errorf("getting node %q from Snapshot: %w", nodeName, err))
|
||||
}
|
||||
return pl.score(pod, nodeInfo)
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ func (pl *CSILimits) Filter(ctx context.Context, _ *framework.CycleState, pod *v
|
||||
|
||||
newVolumes := make(map[string]string)
|
||||
if err := pl.filterAttachableVolumes(csiNode, pod.Spec.Volumes, pod.Namespace, newVolumes); err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
|
||||
// If the pod doesn't have any new CSI volumes, the predicate will always be true
|
||||
@ -104,7 +104,7 @@ func (pl *CSILimits) Filter(ctx context.Context, _ *framework.CycleState, pod *v
|
||||
attachedVolumes := make(map[string]string)
|
||||
for _, existingPod := range nodeInfo.Pods {
|
||||
if err := pl.filterAttachableVolumes(csiNode, existingPod.Pod.Spec.Volumes, existingPod.Pod.Namespace, attachedVolumes); err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ func (pl *nonCSILimits) Filter(ctx context.Context, _ *framework.CycleState, pod
|
||||
|
||||
newVolumes := make(map[string]bool)
|
||||
if err := pl.filterVolumes(pod.Spec.Volumes, pod.Namespace, newVolumes); err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
|
||||
// quick return
|
||||
@ -237,7 +237,7 @@ func (pl *nonCSILimits) Filter(ctx context.Context, _ *framework.CycleState, pod
|
||||
existingVolumes := make(map[string]bool)
|
||||
for _, existingPod := range nodeInfo.Pods {
|
||||
if err := pl.filterVolumes(existingPod.Pod.Spec.Volumes, existingPod.Pod.Namespace, existingVolumes); err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
}
|
||||
numExistingVolumes := len(existingVolumes)
|
||||
|
@ -123,7 +123,7 @@ func (pl *SelectorSpread) NormalizeScore(ctx context.Context, state *framework.C
|
||||
}
|
||||
nodeInfo, err := pl.sharedLister.NodeInfos().Get(scores[i].Name)
|
||||
if err != nil {
|
||||
return framework.NewStatus(framework.Error, fmt.Sprintf("getting node %q from Snapshot: %v", scores[i].Name, err))
|
||||
return framework.AsStatus(fmt.Errorf("getting node %q from Snapshot: %w", scores[i].Name, err))
|
||||
}
|
||||
zoneID := utilnode.GetZoneKey(nodeInfo.Node())
|
||||
if zoneID == "" {
|
||||
@ -154,7 +154,7 @@ func (pl *SelectorSpread) NormalizeScore(ctx context.Context, state *framework.C
|
||||
if haveZones {
|
||||
nodeInfo, err := pl.sharedLister.NodeInfos().Get(scores[i].Name)
|
||||
if err != nil {
|
||||
return framework.NewStatus(framework.Error, fmt.Sprintf("getting node %q from Snapshot: %v", scores[i].Name, err))
|
||||
return framework.AsStatus(fmt.Errorf("getting node %q from Snapshot: %w", scores[i].Name, err))
|
||||
}
|
||||
|
||||
zoneID := utilnode.GetZoneKey(nodeInfo.Node())
|
||||
|
@ -196,7 +196,7 @@ func (pl *VolumeBinding) Filter(ctx context.Context, cs *framework.CycleState, p
|
||||
podVolumes, reasons, err := pl.Binder.FindPodVolumes(pod, state.boundClaims, state.claimsToBind, node)
|
||||
|
||||
if err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
|
||||
if len(reasons) > 0 {
|
||||
|
@ -112,7 +112,7 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod *
|
||||
}
|
||||
pvc, err := pl.pvcLister.PersistentVolumeClaims(pod.Namespace).Get(pvcName)
|
||||
if err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
|
||||
if pvc == nil {
|
||||
@ -144,7 +144,7 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod *
|
||||
|
||||
pv, err := pl.pvLister.Get(pvName)
|
||||
if err != nil {
|
||||
return framework.NewStatus(framework.Error, err.Error())
|
||||
return framework.AsStatus(err)
|
||||
}
|
||||
|
||||
if pv == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user