Blame SOURCES/hyperkube.server-don-t-parse-args-for-any-command.patch

38ffc8
From b123592e8315d15c068adf67fd9aef44d6fc7c55 Mon Sep 17 00:00:00 2001
38ffc8
From: Jan Chaloupka <jchaloup@redhat.com>
38ffc8
Date: Tue, 8 Mar 2016 19:22:24 +0100
38ffc8
Subject: [PATCH] hyperkube.server: don't parse args for any command
38ffc8
38ffc8
---
38ffc8
 cmd/hyperkube/hyperkube.go               | 16 +++++++++-------
38ffc8
 cmd/hyperkube/kube-controller-manager.go |  1 +
38ffc8
 cmd/hyperkube/kube-proxy.go              |  1 +
38ffc8
 cmd/hyperkube/kube-scheduler.go          |  1 +
38ffc8
 cmd/hyperkube/kubectl.go                 |  1 +
38ffc8
 cmd/hyperkube/kubelet.go                 |  1 +
38ffc8
 cmd/hyperkube/server.go                  |  1 +
38ffc8
 7 files changed, 15 insertions(+), 7 deletions(-)
38ffc8
38ffc8
diff --git a/cmd/hyperkube/hyperkube.go b/cmd/hyperkube/hyperkube.go
38ffc8
index 5272c5d..fda068a 100644
38ffc8
--- a/cmd/hyperkube/hyperkube.go
38ffc8
+++ b/cmd/hyperkube/hyperkube.go
38ffc8
@@ -154,14 +154,16 @@ func (hk *HyperKube) Run(args []string) error {
38ffc8
 		return err
38ffc8
 	}
38ffc8
 
38ffc8
-	s.Flags().AddFlagSet(hk.Flags())
38ffc8
-	err = s.Flags().Parse(args)
38ffc8
-	if err != nil || hk.helpFlagVal {
38ffc8
-		if err != nil {
38ffc8
-			hk.Printf("Error: %v\n\n", err)
38ffc8
+	if !s.NoParse {
38ffc8
+		s.Flags().AddFlagSet(hk.Flags())
38ffc8
+		err = s.Flags().Parse(args)
38ffc8
+		if err != nil || hk.helpFlagVal {
38ffc8
+			if err != nil {
38ffc8
+				hk.Printf("Error: %v\n\n", err)
38ffc8
+			}
38ffc8
+			s.Usage()
38ffc8
+			return err
38ffc8
 		}
38ffc8
-		s.Usage()
38ffc8
-		return err
38ffc8
 	}
38ffc8
 
38ffc8
 	verflag.PrintAndExitIfRequested()
38ffc8
diff --git a/cmd/hyperkube/kube-controller-manager.go b/cmd/hyperkube/kube-controller-manager.go
38ffc8
index 009b14a..8c9fd98 100644
38ffc8
--- a/cmd/hyperkube/kube-controller-manager.go
38ffc8
+++ b/cmd/hyperkube/kube-controller-manager.go
38ffc8
@@ -33,6 +33,7 @@ func NewKubeControllerManager() *Server {
38ffc8
 		Run: func(_ *Server, args []string) error {
38ffc8
 			return s.Run(args)
38ffc8
 		},
38ffc8
+		NoParse: false,
38ffc8
 	}
38ffc8
 	s.AddFlags(hks.Flags())
38ffc8
 	return &hks
38ffc8
diff --git a/cmd/hyperkube/kube-proxy.go b/cmd/hyperkube/kube-proxy.go
38ffc8
index cf3b12a..69ea610 100644
38ffc8
--- a/cmd/hyperkube/kube-proxy.go
38ffc8
+++ b/cmd/hyperkube/kube-proxy.go
38ffc8
@@ -33,6 +33,7 @@ func NewKubeProxy() *Server {
38ffc8
 		services and forwarding it to the appropriate pods. It generally runs on
38ffc8
 		nodes next to the Kubelet and proxies traffic from local pods to remote pods.
38ffc8
 		It is also used when handling incoming external traffic.`,
38ffc8
+		NoParse: false,
38ffc8
 	}
38ffc8
 
38ffc8
 	config.AddFlags(hks.Flags())
38ffc8
diff --git a/cmd/hyperkube/kube-scheduler.go b/cmd/hyperkube/kube-scheduler.go
38ffc8
index aba7c4f..7a272de 100644
38ffc8
--- a/cmd/hyperkube/kube-scheduler.go
38ffc8
+++ b/cmd/hyperkube/kube-scheduler.go
38ffc8
@@ -33,6 +33,7 @@ func NewScheduler() *Server {
38ffc8
 		Run: func(_ *Server, args []string) error {
38ffc8
 			return s.Run(args)
38ffc8
 		},
38ffc8
+		NoParse: false,
38ffc8
 	}
38ffc8
 	s.AddFlags(hks.Flags())
38ffc8
 	return &hks
38ffc8
diff --git a/cmd/hyperkube/kubectl.go b/cmd/hyperkube/kubectl.go
38ffc8
index 954422d..f35c75c 100644
38ffc8
--- a/cmd/hyperkube/kubectl.go
38ffc8
+++ b/cmd/hyperkube/kubectl.go
38ffc8
@@ -34,5 +34,6 @@ func NewKubectlServer() *Server {
38ffc8
 			os.Exit(0)
38ffc8
 			return nil
38ffc8
 		},
38ffc8
+		NoParse: true,
38ffc8
 	}
38ffc8
 }
38ffc8
diff --git a/cmd/hyperkube/kubelet.go b/cmd/hyperkube/kubelet.go
38ffc8
index e12b20d..40d9ef1 100644
38ffc8
--- a/cmd/hyperkube/kubelet.go
38ffc8
+++ b/cmd/hyperkube/kubelet.go
38ffc8
@@ -35,6 +35,7 @@ func NewKubelet() *Server {
38ffc8
 		Run: func(_ *Server, _ []string) error {
38ffc8
 			return s.Run(nil)
38ffc8
 		},
38ffc8
+		NoParse: false,
38ffc8
 	}
38ffc8
 	s.AddFlags(hks.Flags())
38ffc8
 	return &hks
38ffc8
diff --git a/cmd/hyperkube/server.go b/cmd/hyperkube/server.go
38ffc8
index 6b6e5ce..0baa814 100644
38ffc8
--- a/cmd/hyperkube/server.go
38ffc8
+++ b/cmd/hyperkube/server.go
38ffc8
@@ -34,6 +34,7 @@ type Server struct {
38ffc8
 	SimpleUsage string        // One line description of the server.
38ffc8
 	Long        string        // Longer free form description of the server
38ffc8
 	Run         serverRunFunc // Run the server.  This is not expected to return.
38ffc8
+	NoParse     bool          // Don't parse options. Some commands do it on their own.
38ffc8
 
38ffc8
 	flags *pflag.FlagSet // Flags for the command (and all dependents)
38ffc8
 	name  string
38ffc8
-- 
38ffc8
1.9.3
38ffc8