Merge pull request #1475 from Garrybest/pr_descheduler
fix descheduler crash
This commit is contained in:
commit
7e6d4f6990
|
@ -24,7 +24,7 @@ spec:
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command:
|
command:
|
||||||
- /bin/karmada-descheduler
|
- /bin/karmada-descheduler
|
||||||
- --karmada-kubeconfig=/etc/kubeconfig
|
- --kubeconfig=/etc/kubeconfig
|
||||||
- --bind-address=0.0.0.0
|
- --bind-address=0.0.0.0
|
||||||
- --v=4
|
- --v=4
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/client-go/tools/leaderelection/resourcelock"
|
||||||
componentbaseconfig "k8s.io/component-base/config"
|
componentbaseconfig "k8s.io/component-base/config"
|
||||||
|
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
@ -18,6 +19,12 @@ const (
|
||||||
defaultUnschedulableThreshold = 5 * time.Minute
|
defaultUnschedulableThreshold = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaultElectionLeaseDuration = metav1.Duration{Duration: 15 * time.Second}
|
||||||
|
defaultElectionRenewDeadline = metav1.Duration{Duration: 10 * time.Second}
|
||||||
|
defaultElectionRetryPeriod = metav1.Duration{Duration: 2 * time.Second}
|
||||||
|
)
|
||||||
|
|
||||||
// Options contains everything necessary to create and run scheduler-estimator.
|
// Options contains everything necessary to create and run scheduler-estimator.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
LeaderElection componentbaseconfig.LeaderElectionConfiguration
|
LeaderElection componentbaseconfig.LeaderElectionConfiguration
|
||||||
|
@ -42,9 +49,19 @@ type Options struct {
|
||||||
UnschedulableThreshold metav1.Duration
|
UnschedulableThreshold metav1.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOptions builds an empty options.
|
// NewOptions builds a default descheduler options.
|
||||||
func NewOptions() *Options {
|
func NewOptions() *Options {
|
||||||
return &Options{}
|
return &Options{
|
||||||
|
LeaderElection: componentbaseconfig.LeaderElectionConfiguration{
|
||||||
|
LeaderElect: true,
|
||||||
|
ResourceLock: resourcelock.LeasesResourceLock,
|
||||||
|
ResourceNamespace: util.NamespaceKarmadaSystem,
|
||||||
|
ResourceName: "karmada-descheduler",
|
||||||
|
LeaseDuration: defaultElectionLeaseDuration,
|
||||||
|
RenewDeadline: defaultElectionRenewDeadline,
|
||||||
|
RetryPeriod: defaultElectionRetryPeriod,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddFlags adds flags of estimator to the specified FlagSet
|
// AddFlags adds flags of estimator to the specified FlagSet
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/kr/pretty"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
|
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
|
||||||
|
@ -75,7 +76,7 @@ func (h *SchedulingResultHelper) FillUnschedulableReplicas(unschedulableThreshol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(4).Infof("Target undesired cluster of unschedulable replica result: %v", undesiredClusters)
|
klog.V(4).Infof("Target undesired cluster of unschedulable replica result: %s", pretty.Sprint(undesiredClusters))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUndesiredClusters returns the cluster which of ready replicas are not reach the ready ones.
|
// GetUndesiredClusters returns the cluster which of ready replicas are not reach the ready ones.
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (d *Descheduler) descheduleOnce() {
|
||||||
}
|
}
|
||||||
bindings = core.FilterBindings(bindings)
|
bindings = core.FilterBindings(bindings)
|
||||||
for _, binding := range bindings {
|
for _, binding := range bindings {
|
||||||
d.deschedulerWorker.Add(binding)
|
d.deschedulerWorker.Enqueue(binding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue