add deprecated flag for flush pods to activeq interval

This commit is contained in:
Alex Wang
2022-02-16 11:05:52 +08:00
parent 2047936f3f
commit 87549203e9
8 changed files with 214 additions and 54 deletions

View File

@@ -17,6 +17,8 @@ limitations under the License.
package config
import (
"time"
apiserver "k8s.io/apiserver/pkg/server"
"k8s.io/client-go/dynamic/dynamicinformer"
"k8s.io/client-go/informers"
@@ -49,6 +51,12 @@ type Config struct {
// LeaderElection is optional.
LeaderElection *leaderelection.LeaderElectionConfig
// PodMaxUnschedulableQDuration is the maximum time a pod can stay in
// unschedulableQ. If a pod stays in unschedulableQ for longer than this
// value, the pod will be moved from unschedulableQ to backoffQ or activeQ.
// If this value is empty, the default value (60s) will be used.
PodMaxUnschedulableQDuration time.Duration
}
type completedConfig struct {

View File

@@ -17,6 +17,8 @@ limitations under the License.
package options
import (
"time"
"github.com/spf13/pflag"
componentbaseconfig "k8s.io/component-base/config"
)
@@ -28,6 +30,11 @@ type DeprecatedOptions struct {
componentbaseconfig.ClientConnectionConfiguration
// Note that only the deprecated options (lock-object-name and lock-object-namespace) are populated here.
componentbaseconfig.LeaderElectionConfiguration
// PodMaxUnschedulableQDuration is the maximum time a pod can stay in
// unschedulableQ. If a pod stays in unschedulableQ for longer than this
// value, the pod will be moved from unschedulableQ to backoffQ or activeQ.
// If this value is empty, the default value (60s) will be used.
PodMaxUnschedulableQDuration time.Duration
}
// AddFlags adds flags for the deprecated options.
@@ -44,4 +51,5 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet) {
fs.Int32Var(&o.Burst, "kube-api-burst", 100, "DEPRECATED: burst to use while talking with kubernetes apiserver. This parameter is ignored if a config file is specified in --config.")
fs.StringVar(&o.ResourceNamespace, "lock-object-namespace", "kube-system", "DEPRECATED: define the namespace of the lock object. Will be removed in favor of leader-elect-resource-namespace. This parameter is ignored if a config file is specified in --config.")
fs.StringVar(&o.ResourceName, "lock-object-name", "kube-scheduler", "DEPRECATED: define the name of the lock object. Will be removed in favor of leader-elect-resource-name. This parameter is ignored if a config file is specified in --config.")
fs.DurationVar(&o.PodMaxUnschedulableQDuration, "pod-max-unschedulableq-duration", 60*time.Second, "DEPRECATED: the maximum time a pod can stay in unschedulableQ. If a pod stays in unschedulableQ for longer than this value, the pod will be moved from unschedulableQ to backoffQ or activeQ. This flag is deprecated and will be removed in 1.26")
}

View File

@@ -79,7 +79,9 @@ func NewOptions() *Options {
SecureServing: apiserveroptions.NewSecureServingOptions().WithLoopback(),
Authentication: apiserveroptions.NewDelegatingAuthenticationOptions(),
Authorization: apiserveroptions.NewDelegatingAuthorizationOptions(),
Deprecated: &DeprecatedOptions{},
Deprecated: &DeprecatedOptions{
PodMaxUnschedulableQDuration: 60 * time.Second,
},
LeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
LeaderElect: true,
LeaseDuration: metav1.Duration{Duration: 15 * time.Second},
@@ -231,6 +233,12 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
}
}
o.Metrics.Apply()
// Apply value independently instead of using ApplyDeprecated() because it can't be configured via ComponentConfig.
if o.Deprecated != nil {
c.PodMaxUnschedulableQDuration = o.Deprecated.PodMaxUnschedulableQDuration
}
return nil
}

View File

@@ -328,6 +328,7 @@ func Setup(ctx context.Context, opts *options.Options, outOfTreeRegistryOptions
scheduler.WithFrameworkOutOfTreeRegistry(outOfTreeRegistry),
scheduler.WithPodMaxBackoffSeconds(cc.ComponentConfig.PodMaxBackoffSeconds),
scheduler.WithPodInitialBackoffSeconds(cc.ComponentConfig.PodInitialBackoffSeconds),
scheduler.WithPodMaxUnschedulableQDuration(cc.PodMaxUnschedulableQDuration),
scheduler.WithExtenders(cc.ComponentConfig.Extenders...),
scheduler.WithParallelism(cc.ComponentConfig.Parallelism),
scheduler.WithBuildFrameworkCapturer(func(profile kubeschedulerconfig.KubeSchedulerProfile) {