fix descheduler crash
Signed-off-by: Garrybest <garrybest@foxmail.com>
This commit is contained in:
parent
ad6b7971da
commit
995a2a4006
|
@ -24,7 +24,7 @@ spec:
|
|||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- /bin/karmada-descheduler
|
||||
- --karmada-kubeconfig=/etc/kubeconfig
|
||||
- --kubeconfig=/etc/kubeconfig
|
||||
- --bind-address=0.0.0.0
|
||||
- --v=4
|
||||
volumeMounts:
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/spf13/pflag"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/tools/leaderelection/resourcelock"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
|
||||
"github.com/karmada-io/karmada/pkg/util"
|
||||
|
@ -18,6 +19,12 @@ const (
|
|||
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.
|
||||
type Options struct {
|
||||
LeaderElection componentbaseconfig.LeaderElectionConfiguration
|
||||
|
@ -42,9 +49,19 @@ type Options struct {
|
|||
UnschedulableThreshold metav1.Duration
|
||||
}
|
||||
|
||||
// NewOptions builds an empty options.
|
||||
// NewOptions builds a default descheduler 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
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/kr/pretty"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
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.
|
||||
|
|
|
@ -128,7 +128,7 @@ func (d *Descheduler) descheduleOnce() {
|
|||
}
|
||||
bindings = core.FilterBindings(bindings)
|
||||
for _, binding := range bindings {
|
||||
d.deschedulerWorker.Add(binding)
|
||||
d.deschedulerWorker.Enqueue(binding)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue