mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #100947 from lojies/cleanuppkgsheduler
code cleanup for pkg/scheduler
This commit is contained in:
commit
1fa101d1a4
@ -21,7 +21,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/util/feature"
|
"k8s.io/apiserver/pkg/util/feature"
|
||||||
componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1"
|
componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1"
|
||||||
@ -53,7 +52,7 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta1.KubeSchedulerConfigurat
|
|||||||
// Only apply a default scheduler name when there is a single profile.
|
// Only apply a default scheduler name when there is a single profile.
|
||||||
// Validation will ensure that every profile has a non-empty unique name.
|
// Validation will ensure that every profile has a non-empty unique name.
|
||||||
if len(obj.Profiles) == 1 && obj.Profiles[0].SchedulerName == nil {
|
if len(obj.Profiles) == 1 && obj.Profiles[0].SchedulerName == nil {
|
||||||
obj.Profiles[0].SchedulerName = pointer.StringPtr(v1.DefaultSchedulerName)
|
obj.Profiles[0].SchedulerName = pointer.StringPtr(corev1.DefaultSchedulerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For Healthz and Metrics bind addresses, we want to check:
|
// For Healthz and Metrics bind addresses, we want to check:
|
||||||
|
@ -75,7 +75,7 @@ func (pl *CSILimits) Filter(ctx context.Context, _ *framework.CycleState, pod *v
|
|||||||
|
|
||||||
node := nodeInfo.Node()
|
node := nodeInfo.Node()
|
||||||
if node == nil {
|
if node == nil {
|
||||||
return framework.NewStatus(framework.Error, fmt.Sprintf("node not found"))
|
return framework.NewStatus(framework.Error, "node not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// If CSINode doesn't exist, the predicate may read the limits from Node object
|
// If CSINode doesn't exist, the predicate may read the limits from Node object
|
||||||
|
@ -215,7 +215,7 @@ func (pl *nonCSILimits) Filter(ctx context.Context, _ *framework.CycleState, pod
|
|||||||
|
|
||||||
node := nodeInfo.Node()
|
node := nodeInfo.Node()
|
||||||
if node == nil {
|
if node == nil {
|
||||||
return framework.NewStatus(framework.Error, fmt.Sprintf("node not found"))
|
return framework.NewStatus(framework.Error, "node not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
var csiNode *storage.CSINode
|
var csiNode *storage.CSINode
|
||||||
|
@ -181,8 +181,7 @@ func (pl *SelectorSpread) PreScore(ctx context.Context, cycleState *framework.Cy
|
|||||||
if skipSelectorSpread(pod) {
|
if skipSelectorSpread(pod) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var selector labels.Selector
|
selector := helper.DefaultSelector(
|
||||||
selector = helper.DefaultSelector(
|
|
||||||
pod,
|
pod,
|
||||||
pl.services,
|
pl.services,
|
||||||
pl.replicationControllers,
|
pl.replicationControllers,
|
||||||
|
@ -123,7 +123,7 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod *
|
|||||||
if pvName == "" {
|
if pvName == "" {
|
||||||
scName := storagehelpers.GetPersistentVolumeClaimClass(pvc)
|
scName := storagehelpers.GetPersistentVolumeClaimClass(pvc)
|
||||||
if len(scName) == 0 {
|
if len(scName) == 0 {
|
||||||
return framework.NewStatus(framework.Error, fmt.Sprint("PersistentVolumeClaim had no pv name and storageClass name"))
|
return framework.NewStatus(framework.Error, "PersistentVolumeClaim had no pv name and storageClass name")
|
||||||
}
|
}
|
||||||
|
|
||||||
class, _ := pl.scLister.Get(scName)
|
class, _ := pl.scLister.Get(scName)
|
||||||
@ -139,7 +139,7 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod *
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return framework.NewStatus(framework.Error, fmt.Sprint("PersistentVolume had no name"))
|
return framework.NewStatus(framework.Error, "PersistentVolume had no name")
|
||||||
}
|
}
|
||||||
|
|
||||||
pv, err := pl.pvLister.Get(pvName)
|
pv, err := pl.pvLister.Get(pvName)
|
||||||
@ -155,7 +155,7 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod *
|
|||||||
if !volumeZoneLabels.Has(k) {
|
if !volumeZoneLabels.Has(k) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nodeV, _ := nodeConstraints[k]
|
nodeV := nodeConstraints[k]
|
||||||
volumeVSet, err := volumehelpers.LabelZonesToSet(v)
|
volumeVSet, err := volumehelpers.LabelZonesToSet(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.InfoS("Failed to parse label, ignoring the label", "label", fmt.Sprintf("%s:%s", k, v), "err", err)
|
klog.InfoS("Failed to parse label, ignoring the label", "label", fmt.Sprintf("%s:%s", k, v), "err", err)
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
ktypes "k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
@ -773,7 +773,7 @@ type nominatedPodMap struct {
|
|||||||
nominatedPods map[string][]*framework.PodInfo
|
nominatedPods map[string][]*framework.PodInfo
|
||||||
// nominatedPodToNode is map keyed by a Pod UID to the node name where it is
|
// nominatedPodToNode is map keyed by a Pod UID to the node name where it is
|
||||||
// nominated.
|
// nominated.
|
||||||
nominatedPodToNode map[ktypes.UID]string
|
nominatedPodToNode map[types.UID]string
|
||||||
|
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
@ -845,7 +845,7 @@ func (npm *nominatedPodMap) UpdateNominatedPod(oldPod *v1.Pod, newPodInfo *frame
|
|||||||
func NewPodNominator() framework.PodNominator {
|
func NewPodNominator() framework.PodNominator {
|
||||||
return &nominatedPodMap{
|
return &nominatedPodMap{
|
||||||
nominatedPods: make(map[string][]*framework.PodInfo),
|
nominatedPods: make(map[string][]*framework.PodInfo),
|
||||||
nominatedPodToNode: make(map[ktypes.UID]string),
|
nominatedPodToNode: make(map[types.UID]string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
ktypes "k8s.io/apimachinery/pkg/types"
|
|
||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/apimachinery/pkg/util/clock"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/component-base/metrics/testutil"
|
"k8s.io/component-base/metrics/testutil"
|
||||||
@ -1670,7 +1669,7 @@ func TestBackOffFlow(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
podID := ktypes.NamespacedName{
|
podID := types.NamespacedName{
|
||||||
Namespace: pod.Namespace,
|
Namespace: pod.Namespace,
|
||||||
Name: pod.Name,
|
Name: pod.Name,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user