Merge pull request #1475 from Garrybest/pr_descheduler

fix descheduler crash
This commit is contained in:
karmada-bot 2022-03-14 09:00:30 +08:00 committed by GitHub
commit 7e6d4f6990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 5 deletions

View File

@ -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:

View File

@ -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

View File

@ -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.

View File

@ -128,7 +128,7 @@ func (d *Descheduler) descheduleOnce() {
}
bindings = core.FilterBindings(bindings)
for _, binding := range bindings {
d.deschedulerWorker.Add(binding)
d.deschedulerWorker.Enqueue(binding)
}
}