Skip to content

Commit

Permalink
Merge branch 'kubernetes:master' into fix_write_sysfs
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjmmi committed Oct 13, 2021
2 parents a453b25 + f0e80a6 commit 019f335
Show file tree
Hide file tree
Showing 125 changed files with 2,153 additions and 2,459 deletions.
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions cmd/kube-controller-manager/app/core.go
Expand Up @@ -573,9 +573,6 @@ func startPVProtectionController(ctx context.Context, controllerContext Controll
}

func startTTLAfterFinishedController(ctx context.Context, controllerContext ControllerContext) (controller.Interface, bool, error) {
if !utilfeature.DefaultFeatureGate.Enabled(features.TTLAfterFinished) {
return nil, false, nil
}
go ttlafterfinished.New(
controllerContext.InformerFactory.Batch().V1().Jobs(),
controllerContext.ClientBuilder.ClientOrDie("ttl-after-finished-controller"),
Expand Down
3 changes: 1 addition & 2 deletions cmd/kube-proxy/app/server.go
Expand Up @@ -523,8 +523,7 @@ with the apiserver API to configure the proxy.`,
opts.AddFlags(fs)
fs.AddGoFlagSet(goflag.CommandLine) // for --boot-id-file and --machine-id-file

// TODO handle error
cmd.MarkFlagFilename("config", "yaml", "yml", "json")
_ = cmd.MarkFlagFilename("config", "yaml", "yml", "json")

return cmd
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/kube-scheduler/app/config/config.go
Expand Up @@ -32,8 +32,6 @@ type Config struct {
// ComponentConfig is the scheduler server's configuration object.
ComponentConfig kubeschedulerconfig.KubeSchedulerConfiguration

LegacyPolicySource *kubeschedulerconfig.SchedulerPolicySource

// LoopbackClientConfig is a config for a privileged loopback connection
LoopbackClientConfig *restclient.Config

Expand Down
43 changes: 1 addition & 42 deletions cmd/kube-scheduler/app/options/deprecated.go
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/validation/field"
schedulerappconfig "k8s.io/kubernetes/cmd/kube-scheduler/app/config"
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
)

Expand All @@ -31,11 +30,7 @@ import (
type DeprecatedOptions struct {
// The fields below here are placeholders for flags that can't be directly
// mapped into componentconfig.KubeSchedulerConfiguration.
PolicyConfigFile string
PolicyConfigMapName string
PolicyConfigMapNamespace string
UseLegacyPolicyConfig bool
Port int
Port int
}

// TODO: remove these insecure flags in v1.24
Expand All @@ -59,12 +54,6 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet, cfg *kubeschedulerconfig

addDummyInsecureFlags(o, fs)

fs.StringVar(&o.PolicyConfigFile, "policy-config-file", o.PolicyConfigFile, "DEPRECATED: file with scheduler policy configuration. This file is used if policy ConfigMap is not provided or --use-legacy-policy-config=true. Note: The predicates/priorities defined in this file will take precedence over any profiles define in ComponentConfig.")
usage := fmt.Sprintf("DEPRECATED: name of the ConfigMap object that contains scheduler's policy configuration. It must exist in the system namespace before scheduler initialization if --use-legacy-policy-config=false. The config must be provided as the value of an element in 'Data' map with the key='%v'. Note: The predicates/priorities defined in this file will take precedence over any profiles define in ComponentConfig.", kubeschedulerconfig.SchedulerPolicyConfigMapKey)
fs.StringVar(&o.PolicyConfigMapName, "policy-configmap", o.PolicyConfigMapName, usage)
fs.StringVar(&o.PolicyConfigMapNamespace, "policy-configmap-namespace", o.PolicyConfigMapNamespace, "DEPRECATED: the namespace where policy ConfigMap is located. The kube-system namespace will be used if this is not provided or is empty. Note: The predicates/priorities defined in this file will take precedence over any profiles define in ComponentConfig.")
fs.BoolVar(&o.UseLegacyPolicyConfig, "use-legacy-policy-config", o.UseLegacyPolicyConfig, "DEPRECATED: when set to true, scheduler will ignore policy ConfigMap and uses policy config file. Note: The scheduler will fail if this is combined with Plugin configs")

fs.BoolVar(&cfg.EnableProfiling, "profiling", cfg.EnableProfiling, "DEPRECATED: enable profiling via web interface host:port/debug/pprof/. This parameter is ignored if a config file is specified in --config.")
fs.BoolVar(&cfg.EnableContentionProfiling, "contention-profiling", cfg.EnableContentionProfiling, "DEPRECATED: enable lock contention profiling, if profiling is enabled. This parameter is ignored if a config file is specified in --config.")
fs.StringVar(&cfg.ClientConnection.Kubeconfig, "kubeconfig", cfg.ClientConnection.Kubeconfig, "DEPRECATED: path to kubeconfig file with authorization and master location information. This parameter is ignored if a config file is specified in --config.")
Expand All @@ -79,39 +68,9 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet, cfg *kubeschedulerconfig
func (o *DeprecatedOptions) Validate() []error {
var errs []error

if o.UseLegacyPolicyConfig && len(o.PolicyConfigFile) == 0 {
errs = append(errs, field.Required(field.NewPath("policyConfigFile"), "required when --use-legacy-policy-config is true"))
}

// TODO: delete this check after insecure flags removed in v1.24
if o.Port != 0 {
errs = append(errs, field.Required(field.NewPath("port"), fmt.Sprintf("invalid port value %d: only zero is allowed", o.Port)))
}
return errs
}

// ApplyTo sets cfg.PolicySource from flags passed on the command line in the following precedence order:
//
// 1. --use-legacy-policy-config to use a policy file.
// 2. --policy-configmap to use a policy config map value.
func (o *DeprecatedOptions) ApplyTo(c *schedulerappconfig.Config) {
if o == nil {
return
}

switch {
case o.UseLegacyPolicyConfig || (len(o.PolicyConfigFile) > 0 && o.PolicyConfigMapName == ""):
c.LegacyPolicySource = &kubeschedulerconfig.SchedulerPolicySource{
File: &kubeschedulerconfig.SchedulerPolicyFileSource{
Path: o.PolicyConfigFile,
},
}
case len(o.PolicyConfigMapName) > 0:
c.LegacyPolicySource = &kubeschedulerconfig.SchedulerPolicySource{
ConfigMap: &kubeschedulerconfig.SchedulerPolicyConfigMapSource{
Name: o.PolicyConfigMapName,
Namespace: o.PolicyConfigMapNamespace,
},
}
}
}
52 changes: 0 additions & 52 deletions cmd/kube-scheduler/app/options/deprecated_test.go

This file was deleted.

26 changes: 4 additions & 22 deletions cmd/kube-scheduler/app/options/options.go
Expand Up @@ -23,7 +23,6 @@ import (
"time"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
apiserveroptions "k8s.io/apiserver/pkg/server/options"
utilfeature "k8s.io/apiserver/pkg/util/feature"
Expand Down Expand Up @@ -76,12 +75,9 @@ func NewOptions() (*Options, error) {
SecureServing: apiserveroptions.NewSecureServingOptions().WithLoopback(),
Authentication: apiserveroptions.NewDelegatingAuthenticationOptions(),
Authorization: apiserveroptions.NewDelegatingAuthorizationOptions(),
Deprecated: &DeprecatedOptions{
UseLegacyPolicyConfig: false,
PolicyConfigMapNamespace: metav1.NamespaceSystem,
},
Metrics: metrics.NewOptions(),
Logs: logs.NewOptions(),
Deprecated: &DeprecatedOptions{},
Metrics: metrics.NewOptions(),
Logs: logs.NewOptions(),
}

o.Authentication.TolerateInClusterLookupFailure = true
Expand Down Expand Up @@ -161,10 +157,7 @@ func (o *Options) Complete(nfs *cliflag.NamedFlagSets) error {
// Flags returns flags for a specific scheduler by section name
func (o *Options) Flags() (nfs cliflag.NamedFlagSets) {
fs := nfs.FlagSet("misc")
fs.StringVar(&o.ConfigFile, "config", o.ConfigFile, `The path to the configuration file. The following flags can overwrite fields in this file:
--policy-config-file
--policy-configmap
--policy-configmap-namespace`)
fs.StringVar(&o.ConfigFile, "config", o.ConfigFile, "The path to the configuration file.")
fs.StringVar(&o.WriteConfigTo, "write-config-to", o.WriteConfigTo, "If set, write the configuration values to this file and exit.")
fs.StringVar(&o.Master, "master", o.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")

Expand All @@ -185,8 +178,6 @@ func (o *Options) Flags() (nfs cliflag.NamedFlagSets) {
func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
if len(o.ConfigFile) == 0 {
c.ComponentConfig = o.ComponentConfig

o.Deprecated.ApplyTo(c)
} else {
cfg, err := loadConfigFromFile(o.ConfigFile)
if err != nil {
Expand All @@ -197,15 +188,6 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
}

c.ComponentConfig = *cfg

// apply any deprecated Policy flags, if applicable
o.Deprecated.ApplyTo(c)
}

// If the user is using the legacy policy config, clear the profiles, they will be set
// on scheduler instantiation based on the configurations in the policy file.
if c.LegacyPolicySource != nil {
c.ComponentConfig.Profiles = nil
}

if err := o.SecureServing.ApplyTo(&c.SecureServing, &c.LoopbackClientConfig); err != nil {
Expand Down
39 changes: 0 additions & 39 deletions cmd/kube-scheduler/app/options/options_test.go
Expand Up @@ -1120,45 +1120,6 @@ profiles:
},
},
},
{
name: "Attempting to set Component Config Profiles and Policy config",
options: &Options{
ConfigFile: pluginConfigFile,
Deprecated: &DeprecatedOptions{
PolicyConfigMapName: "bar",
},
Logs: logs.NewOptions(),
},
expectedUsername: "config",
expectedConfig: kubeschedulerconfig.KubeSchedulerConfiguration{
TypeMeta: metav1.TypeMeta{
APIVersion: v1beta3.SchemeGroupVersion.String(),
},
Parallelism: 16,
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
EnableProfiling: true,
EnableContentionProfiling: true,
},
LeaderElection: componentbaseconfig.LeaderElectionConfiguration{
LeaderElect: true,
LeaseDuration: metav1.Duration{Duration: 15 * time.Second},
RenewDeadline: metav1.Duration{Duration: 10 * time.Second},
RetryPeriod: metav1.Duration{Duration: 2 * time.Second},
ResourceLock: "leases",
ResourceNamespace: "kube-system",
ResourceName: "kube-scheduler",
},
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
Kubeconfig: configKubeconfig,
QPS: 50,
Burst: 100,
ContentType: "application/vnd.kubernetes.protobuf",
},
PercentageOfNodesToScore: defaultPercentageOfNodesToScore,
PodInitialBackoffSeconds: defaultPodInitialBackoffSeconds,
PodMaxBackoffSeconds: defaultPodMaxBackoffSeconds,
},
},
{
name: "no config",
options: &Options{
Expand Down
6 changes: 1 addition & 5 deletions cmd/kube-scheduler/app/server.go
Expand Up @@ -83,10 +83,7 @@ for more information about scheduling and the kube-scheduler component.`,
if err := opts.Complete(&namedFlagSets); err != nil {
return err
}
if err := runCommand(cmd, opts, registryOptions...); err != nil {
return err
}
return nil
return runCommand(cmd, opts, registryOptions...)
},
Args: func(cmd *cobra.Command, args []string) error {
for _, arg := range args {
Expand Down Expand Up @@ -316,7 +313,6 @@ func Setup(ctx context.Context, opts *options.Options, outOfTreeRegistryOptions
scheduler.WithComponentConfigVersion(cc.ComponentConfig.TypeMeta.APIVersion),
scheduler.WithKubeConfig(cc.KubeConfig),
scheduler.WithProfiles(cc.ComponentConfig.Profiles...),
scheduler.WithLegacyPolicySource(cc.LegacyPolicySource),
scheduler.WithPercentageOfNodesToScore(cc.ComponentConfig.PercentageOfNodesToScore),
scheduler.WithFrameworkOutOfTreeRegistry(outOfTreeRegistry),
scheduler.WithPodMaxBackoffSeconds(cc.ComponentConfig.PodMaxBackoffSeconds),
Expand Down
37 changes: 0 additions & 37 deletions cmd/kube-scheduler/app/server_test.go
Expand Up @@ -139,19 +139,6 @@ profiles:
t.Fatal(err)
}

// policy config file
policyConfigFile := filepath.Join(tmpDir, "policy-config.yaml")
if err := ioutil.WriteFile(policyConfigFile, []byte(`{
"kind": "Policy",
"apiVersion": "v1",
"predicates": [
{"name": "MatchInterPodAffinity"}
],"priorities": [
{"name": "InterPodAffinityPriority", "weight": 2}
]}`), os.FileMode(0600)); err != nil {
t.Fatal(err)
}

testcases := []struct {
name string
flags []string
Expand Down Expand Up @@ -206,30 +193,6 @@ profiles:
},
},
},
{
name: "policy config file",
flags: []string{
"--kubeconfig", configKubeconfig,
"--policy-config-file", policyConfigFile,
},
wantPlugins: map[string]*config.Plugins{
"default-scheduler": {
QueueSort: config.PluginSet{Enabled: []config.Plugin{{Name: "PrioritySort"}}},
PreFilter: config.PluginSet{Enabled: []config.Plugin{{Name: "InterPodAffinity"}}},
Filter: config.PluginSet{
Enabled: []config.Plugin{
{Name: "NodeUnschedulable"},
{Name: "TaintToleration"},
{Name: "InterPodAffinity"},
},
},
PostFilter: config.PluginSet{Enabled: []config.Plugin{{Name: "DefaultPreemption"}}},
PreScore: config.PluginSet{Enabled: []config.Plugin{{Name: "InterPodAffinity"}}},
Score: config.PluginSet{Enabled: []config.Plugin{{Name: "InterPodAffinity", Weight: 2}}},
Bind: config.PluginSet{Enabled: []config.Plugin{{Name: "DefaultBinder"}}},
},
},
},
}

makeListener := func(t *testing.T) net.Listener {
Expand Down
4 changes: 2 additions & 2 deletions hack/lib/golang.sh
Expand Up @@ -211,8 +211,8 @@ kube::golang::setup_platforms() {

elif [[ "${KUBE_FASTBUILD:-}" == "true" ]]; then
host_arch=$(kube::util::host_arch)
if [[ "${host_arch}" != "amd64" && "${host_arch}" != "arm64" ]]; then
# on any platform other than amd64 and arm64, we just default to amd64
if [[ "${host_arch}" != "amd64" && "${host_arch}" != "arm64" && "${host_arch}" != "ppc64le" ]]; then
# on any platform other than amd64, arm64 and ppc64le, we just default to amd64
host_arch="amd64"
fi
KUBE_SERVER_PLATFORMS=("linux/${host_arch}")
Expand Down
1 change: 1 addition & 0 deletions hack/make-rules/verify.sh
Expand Up @@ -80,6 +80,7 @@ QUICK_PATTERNS+=(
"verify-vendor-licenses.sh"
"verify-gofmt.sh"
"verify-imports.sh"
"verify-non-mutating-validation.sh"
"verify-pkg-names.sh"
"verify-readonly-packages.sh"
"verify-spelling.sh"
Expand Down

0 comments on commit 019f335

Please sign in to comment.