From ed289f875e32d6dc66e2477b0287cd998dc8e7ab Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 19 Jan 2024 10:05:04 -0500 Subject: [PATCH] Remove some dead options in KubeSchedulerConfiguration The v1beta1 API had MetricsBindAddress and HealthzBindAddress fields but they were removed in v1, and then never got removed from the unversioned type when the v1beta1 API went away. --- pkg/scheduler/apis/config/types.go | 4 -- .../apis/config/v1/zz_generated.conversion.go | 2 - .../apis/config/validation/validation.go | 41 ------------------- .../apis/config/validation/validation_test.go | 24 ----------- 4 files changed, 71 deletions(-) diff --git a/pkg/scheduler/apis/config/types.go b/pkg/scheduler/apis/config/types.go index 142ecb08ef4..b0c94a18eef 100644 --- a/pkg/scheduler/apis/config/types.go +++ b/pkg/scheduler/apis/config/types.go @@ -54,10 +54,6 @@ type KubeSchedulerConfiguration struct { // ClientConnection specifies the kubeconfig file and client connection // settings for the proxy server to use when communicating with the apiserver. ClientConnection componentbaseconfig.ClientConnectionConfiguration - // HealthzBindAddress is the IP address and port for the health check server to serve on. - HealthzBindAddress string - // MetricsBindAddress is the IP address and port for the metrics server to serve on. - MetricsBindAddress string // DebuggingConfiguration holds configuration for Debugging related features // TODO: We might wanna make this a substruct like Debugging componentbaseconfig.DebuggingConfiguration diff --git a/pkg/scheduler/apis/config/v1/zz_generated.conversion.go b/pkg/scheduler/apis/config/v1/zz_generated.conversion.go index ca9be957b42..0e544a579cf 100644 --- a/pkg/scheduler/apis/config/v1/zz_generated.conversion.go +++ b/pkg/scheduler/apis/config/v1/zz_generated.conversion.go @@ -443,8 +443,6 @@ func autoConvert_config_KubeSchedulerConfiguration_To_v1_KubeSchedulerConfigurat if err := v1alpha1.Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(&in.ClientConnection, &out.ClientConnection, s); err != nil { return err } - // WARNING: in.HealthzBindAddress requires manual conversion: does not exist in peer-type - // WARNING: in.MetricsBindAddress requires manual conversion: does not exist in peer-type if err := v1alpha1.Convert_config_DebuggingConfiguration_To_v1alpha1_DebuggingConfiguration(&in.DebuggingConfiguration, &out.DebuggingConfiguration, s); err != nil { return err } diff --git a/pkg/scheduler/apis/config/validation/validation.go b/pkg/scheduler/apis/config/validation/validation.go index 9d61c8cf861..525e613d013 100644 --- a/pkg/scheduler/apis/config/validation/validation.go +++ b/pkg/scheduler/apis/config/validation/validation.go @@ -18,10 +18,7 @@ package validation import ( "fmt" - "net" "reflect" - "strconv" - "strings" v1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -68,32 +65,6 @@ func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) u } errs = append(errs, validateCommonQueueSort(profilesPath, cc.Profiles)...) } - if len(cc.HealthzBindAddress) > 0 { - host, port, err := splitHostIntPort(cc.HealthzBindAddress) - if err != nil { - errs = append(errs, field.Invalid(field.NewPath("healthzBindAddress"), cc.HealthzBindAddress, err.Error())) - } else { - if errMsgs := validation.IsValidIP(host); errMsgs != nil { - errs = append(errs, field.Invalid(field.NewPath("healthzBindAddress"), cc.HealthzBindAddress, strings.Join(errMsgs, ","))) - } - if port != 0 { - errs = append(errs, field.Invalid(field.NewPath("healthzBindAddress"), cc.HealthzBindAddress, "must be empty or with an explicit 0 port")) - } - } - } - if len(cc.MetricsBindAddress) > 0 { - host, port, err := splitHostIntPort(cc.MetricsBindAddress) - if err != nil { - errs = append(errs, field.Invalid(field.NewPath("metricsBindAddress"), cc.MetricsBindAddress, err.Error())) - } else { - if errMsgs := validation.IsValidIP(host); errMsgs != nil { - errs = append(errs, field.Invalid(field.NewPath("metricsBindAddress"), cc.MetricsBindAddress, strings.Join(errMsgs, ","))) - } - if port != 0 { - errs = append(errs, field.Invalid(field.NewPath("metricsBindAddress"), cc.MetricsBindAddress, "must be empty or with an explicit 0 port")) - } - } - } errs = append(errs, validatePercentageOfNodesToScore(field.NewPath("percentageOfNodesToScore"), cc.PercentageOfNodesToScore)) @@ -110,18 +81,6 @@ func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) u return utilerrors.Flatten(utilerrors.NewAggregate(errs)) } -func splitHostIntPort(s string) (string, int, error) { - host, port, err := net.SplitHostPort(s) - if err != nil { - return "", 0, err - } - portInt, err := strconv.Atoi(port) - if err != nil { - return "", 0, err - } - return host, portInt, err -} - func validatePercentageOfNodesToScore(path *field.Path, percentageOfNodesToScore *int32) error { if percentageOfNodesToScore != nil { if *percentageOfNodesToScore < 0 || *percentageOfNodesToScore > 100 { diff --git a/pkg/scheduler/apis/config/validation/validation_test.go b/pkg/scheduler/apis/config/validation/validation_test.go index f25039b369e..aa3aff8f1fc 100644 --- a/pkg/scheduler/apis/config/validation/validation_test.go +++ b/pkg/scheduler/apis/config/validation/validation_test.go @@ -103,12 +103,6 @@ func TestValidateKubeSchedulerConfigurationV1(t *testing.T) { enableContentProfilingSetWithoutEnableProfiling.EnableProfiling = false enableContentProfilingSetWithoutEnableProfiling.EnableContentionProfiling = true - metricsBindAddrInvalid := validConfig.DeepCopy() - metricsBindAddrInvalid.MetricsBindAddress = "0.0.0.0:9090" - - healthzBindAddrInvalid := validConfig.DeepCopy() - healthzBindAddrInvalid.HealthzBindAddress = "0.0.0.0:9090" - percentageOfNodesToScore101 := validConfig.DeepCopy() percentageOfNodesToScore101.PercentageOfNodesToScore = ptr.To[int32](101) @@ -238,24 +232,6 @@ func TestValidateKubeSchedulerConfigurationV1(t *testing.T) { }, }, }, - "non-empty-metrics-bind-addr": { - config: metricsBindAddrInvalid, - wantErrs: field.ErrorList{ - &field.Error{ - Type: field.ErrorTypeInvalid, - Field: "metricsBindAddress", - }, - }, - }, - "non-empty-healthz-bind-addr": { - config: healthzBindAddrInvalid, - wantErrs: field.ErrorList{ - &field.Error{ - Type: field.ErrorTypeInvalid, - Field: "healthzBindAddress", - }, - }, - }, "bad-percentage-of-nodes-to-score": { config: percentageOfNodesToScore101, wantErrs: field.ErrorList{