@@ -28,7 +28,7 @@ import (
28
28
"strings"
29
29
"time"
30
30
31
- v1 "k8s.io/api/core/v1"
31
+ "k8s.io/api/core/v1"
32
32
v1meta "k8s.io/apimachinery/pkg/apis/meta/v1"
33
33
"k8s.io/apimachinery/pkg/runtime"
34
34
"k8s.io/apimachinery/pkg/runtime/serializer"
@@ -39,7 +39,7 @@ import (
39
39
"k8s.io/apiserver/pkg/server/mux"
40
40
"k8s.io/apiserver/pkg/server/routes"
41
41
utilfeature "k8s.io/apiserver/pkg/util/feature"
42
- informers "k8s.io/client-go/informers"
42
+ "k8s.io/client-go/informers"
43
43
clientset "k8s.io/client-go/kubernetes"
44
44
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
45
45
"k8s.io/client-go/rest"
@@ -352,6 +352,7 @@ func (o *Options) writeConfigFile() error {
352
352
if err != nil {
353
353
return err
354
354
}
355
+ // TODO handle error
355
356
defer configFile .Close ()
356
357
357
358
if err := encoder .Encode (o .config , configFile ); err != nil {
@@ -414,11 +415,11 @@ func (o *Options) loadConfig(data []byte) (*kubeproxyconfig.KubeProxyConfigurati
414
415
if err != nil {
415
416
return nil , err
416
417
}
417
- config , ok := configObj .(* kubeproxyconfig.KubeProxyConfiguration )
418
+ proxyConfig , ok := configObj .(* kubeproxyconfig.KubeProxyConfiguration )
418
419
if ! ok {
419
420
return nil , fmt .Errorf ("got unexpected config type: %v" , gvk )
420
421
}
421
- return config , nil
422
+ return proxyConfig , nil
422
423
}
423
424
424
425
func (o * Options ) ApplyDefaults (in * kubeproxyconfig.KubeProxyConfiguration ) (* kubeproxyconfig.KubeProxyConfiguration , error ) {
@@ -478,6 +479,7 @@ with the apiserver API to configure the proxy.`,
478
479
479
480
opts .AddFlags (cmd .Flags ())
480
481
482
+ // TODO handle error
481
483
cmd .MarkFlagFilename ("config" , "yaml" , "yml" , "json" )
482
484
483
485
return cmd
@@ -534,7 +536,6 @@ func createClients(config componentbaseconfig.ClientConnectionConfiguration, mas
534
536
kubeConfig .AcceptContentTypes = config .AcceptContentTypes
535
537
kubeConfig .ContentType = config .ContentType
536
538
kubeConfig .QPS = config .QPS
537
- //TODO make config struct use int instead of int32?
538
539
kubeConfig .Burst = int (config .Burst )
539
540
540
541
client , err := clientset .NewForConfig (kubeConfig )
@@ -560,7 +561,7 @@ func (s *ProxyServer) Run() error {
560
561
encounteredError = iptables .CleanupLeftovers (s .IptInterface ) || encounteredError
561
562
encounteredError = ipvs .CleanupLeftovers (s .IpvsInterface , s .IptInterface , s .IpsetInterface , s .CleanupIPVS ) || encounteredError
562
563
if encounteredError {
563
- return errors .New ("encountered an error while tearing down rules. " )
564
+ return errors .New ("encountered an error while tearing down rules" )
564
565
}
565
566
return nil
566
567
}
@@ -594,18 +595,18 @@ func (s *ProxyServer) Run() error {
594
595
595
596
// Start up a metrics server if requested
596
597
if len (s .MetricsBindAddress ) > 0 {
597
- mux := mux .NewPathRecorderMux ("kube-proxy" )
598
- healthz .InstallHandler (mux )
599
- mux .HandleFunc ("/proxyMode" , func (w http.ResponseWriter , r * http.Request ) {
598
+ proxyMux := mux .NewPathRecorderMux ("kube-proxy" )
599
+ healthz .InstallHandler (proxyMux )
600
+ proxyMux .HandleFunc ("/proxyMode" , func (w http.ResponseWriter , r * http.Request ) {
600
601
fmt .Fprintf (w , "%s" , s .ProxyMode )
601
602
})
602
- mux .Handle ("/metrics" , prometheus .Handler ())
603
+ proxyMux .Handle ("/metrics" , prometheus .Handler ())
603
604
if s .EnableProfiling {
604
- routes.Profiling {}.Install (mux )
605
+ routes.Profiling {}.Install (proxyMux )
605
606
}
606
- configz .InstallHandler (mux )
607
+ configz .InstallHandler (proxyMux )
607
608
go wait .Until (func () {
608
- err := http .ListenAndServe (s .MetricsBindAddress , mux )
609
+ err := http .ListenAndServe (s .MetricsBindAddress , proxyMux )
609
610
if err != nil {
610
611
utilruntime .HandleError (fmt .Errorf ("starting metrics server failed: %v" , err ))
611
612
}
0 commit comments