mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
code cleanup: modify kube-scheduler, remove useless return value
This commit is contained in:
parent
743ceb7e73
commit
f29d0b548e
@ -53,12 +53,8 @@ func (o *CombinedInsecureServingOptions) AddFlags(fs *pflag.FlagSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *CombinedInsecureServingOptions) applyTo(c *schedulerappconfig.Config, componentConfig *kubeschedulerconfig.KubeSchedulerConfiguration) error {
|
func (o *CombinedInsecureServingOptions) applyTo(c *schedulerappconfig.Config, componentConfig *kubeschedulerconfig.KubeSchedulerConfiguration) error {
|
||||||
if err := updateAddressFromDeprecatedInsecureServingOptions(&componentConfig.HealthzBindAddress, o.Healthz); err != nil {
|
updateAddressFromDeprecatedInsecureServingOptions(&componentConfig.HealthzBindAddress, o.Healthz)
|
||||||
return err
|
updateAddressFromDeprecatedInsecureServingOptions(&componentConfig.MetricsBindAddress, o.Metrics)
|
||||||
}
|
|
||||||
if err := updateAddressFromDeprecatedInsecureServingOptions(&componentConfig.MetricsBindAddress, o.Metrics); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := o.Healthz.ApplyTo(&c.InsecureServing, &c.LoopbackClientConfig); err != nil {
|
if err := o.Healthz.ApplyTo(&c.InsecureServing, &c.LoopbackClientConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -98,20 +94,18 @@ func (o *CombinedInsecureServingOptions) ApplyToFromLoadedConfig(c *schedulerapp
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := updateDeprecatedInsecureServingOptionsFromAddress(o.Healthz, componentConfig.HealthzBindAddress); err != nil {
|
updateDeprecatedInsecureServingOptionsFromAddress(o.Healthz, componentConfig.HealthzBindAddress)
|
||||||
return fmt.Errorf("invalid healthz address: %v", err)
|
updateDeprecatedInsecureServingOptionsFromAddress(o.Metrics, componentConfig.MetricsBindAddress)
|
||||||
}
|
|
||||||
if err := updateDeprecatedInsecureServingOptionsFromAddress(o.Metrics, componentConfig.MetricsBindAddress); err != nil {
|
|
||||||
return fmt.Errorf("invalid metrics address: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return o.applyTo(c, componentConfig)
|
return o.applyTo(c, componentConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAddressFromDeprecatedInsecureServingOptions(addr *string, is *apiserveroptions.DeprecatedInsecureServingOptionsWithLoopback) error {
|
func updateAddressFromDeprecatedInsecureServingOptions(addr *string, is *apiserveroptions.DeprecatedInsecureServingOptionsWithLoopback) {
|
||||||
if is == nil {
|
if is == nil {
|
||||||
*addr = ""
|
*addr = ""
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if is.Listener != nil {
|
if is.Listener != nil {
|
||||||
*addr = is.Listener.Addr().String()
|
*addr = is.Listener.Addr().String()
|
||||||
} else if is.BindPort == 0 {
|
} else if is.BindPort == 0 {
|
||||||
@ -121,27 +115,19 @@ func updateAddressFromDeprecatedInsecureServingOptions(addr *string, is *apiserv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
func updateDeprecatedInsecureServingOptionsFromAddress(is *apiserveroptions.DeprecatedInsecureServingOptionsWithLoopback, addr string) {
|
||||||
|
if is == nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateDeprecatedInsecureServingOptionsFromAddress(is *apiserveroptions.DeprecatedInsecureServingOptionsWithLoopback, addr string) error {
|
|
||||||
if is == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if len(addr) == 0 {
|
if len(addr) == 0 {
|
||||||
is.BindPort = 0
|
is.BindPort = 0
|
||||||
return nil
|
} else {
|
||||||
}
|
// In the previous `validate` process, we can ensure that the `addr` is legal, so ignore the error
|
||||||
|
host, portInt, _ := splitHostIntPort(addr)
|
||||||
host, portInt, err := splitHostIntPort(addr)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("invalid address %q", addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
is.BindAddress = net.ParseIP(host)
|
is.BindAddress = net.ParseIP(host)
|
||||||
is.BindPort = portInt
|
is.BindPort = portInt
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates the insecure serving options.
|
// Validate validates the insecure serving options.
|
||||||
|
Loading…
Reference in New Issue
Block a user