mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	normalize -etcd_servers flag across all commands
The -etcd_servers flag is used inconsistently by the Kubernetes commands, both externally and internally. This patch fixes the issue by using the same type to represent a list of etcd servers internally, and declares the -etcd_servers flag consistently across all commands. This patch should be 100% backwards compatible with no changes in behavior.
This commit is contained in:
		@@ -42,7 +42,7 @@ var (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	flag.Var(&etcdServerList, "etcd_servers", "Servers for the etcd (http://ip:port), comma separated")
 | 
						flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated")
 | 
				
			||||||
	flag.Var(&machineList, "machines", "List of machines to schedule onto, comma separated.")
 | 
						flag.Var(&machineList, "machines", "List of machines to schedule onto, comma separated.")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,16 +33,20 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	etcdServers = flag.String("etcd_servers", "", "Servers for the etcd (http://ip:port).")
 | 
						etcdServerList util.StringList
 | 
				
			||||||
	master      = flag.String("master", "", "The address of the Kubernetes API server")
 | 
						master         = flag.String("master", "", "The address of the Kubernetes API server")
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
	flag.Parse()
 | 
						flag.Parse()
 | 
				
			||||||
	util.InitLogs()
 | 
						util.InitLogs()
 | 
				
			||||||
	defer util.FlushLogs()
 | 
						defer util.FlushLogs()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(*etcdServers) == 0 || len(*master) == 0 {
 | 
						if len(etcdServerList) == 0 || len(*master) == 0 {
 | 
				
			||||||
		glog.Fatal("usage: controller-manager -etcd_servers <servers> -master <master>")
 | 
							glog.Fatal("usage: controller-manager -etcd_servers <servers> -master <master>")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,7 +54,7 @@ func main() {
 | 
				
			|||||||
	etcd.SetLogger(util.NewLogger("etcd "))
 | 
						etcd.SetLogger(util.NewLogger("etcd "))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	controllerManager := controller.MakeReplicationManager(
 | 
						controllerManager := controller.MakeReplicationManager(
 | 
				
			||||||
		etcd.NewClient([]string{*etcdServers}),
 | 
							etcd.NewClient(etcdServerList),
 | 
				
			||||||
		client.New("http://"+*master, nil))
 | 
							client.New("http://"+*master, nil))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	controllerManager.Run(10 * time.Second)
 | 
						controllerManager.Run(10 * time.Second)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -106,7 +106,7 @@ func startComponents(manifestURL string) (apiServerURL string) {
 | 
				
			|||||||
		SyncFrequency:      5 * time.Second,
 | 
							SyncFrequency:      5 * time.Second,
 | 
				
			||||||
		HTTPCheckFrequency: 5 * time.Second,
 | 
							HTTPCheckFrequency: 5 * time.Second,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	go myKubelet.RunKubelet("", "", manifestURL, servers[0], "localhost", 10250)
 | 
						go myKubelet.RunKubelet("", "", manifestURL, servers, "localhost", 10250)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Create a second kubelet so that the guestbook example's two redis slaves both
 | 
						// Create a second kubelet so that the guestbook example's two redis slaves both
 | 
				
			||||||
	// have a place they can schedule.
 | 
						// have a place they can schedule.
 | 
				
			||||||
@@ -118,7 +118,7 @@ func startComponents(manifestURL string) (apiServerURL string) {
 | 
				
			|||||||
		SyncFrequency:      5 * time.Second,
 | 
							SyncFrequency:      5 * time.Second,
 | 
				
			||||||
		HTTPCheckFrequency: 5 * time.Second,
 | 
							HTTPCheckFrequency: 5 * time.Second,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	go otherKubelet.RunKubelet("", "", "", servers[0], "localhost", 10251)
 | 
						go otherKubelet.RunKubelet("", "", "", servers, "localhost", 10251)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return apiserver.URL
 | 
						return apiserver.URL
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,6 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	config             = flag.String("config", "", "Path to the config file or directory of files")
 | 
						config             = flag.String("config", "", "Path to the config file or directory of files")
 | 
				
			||||||
	etcdServers        = flag.String("etcd_servers", "", "Url of etcd servers in the cluster")
 | 
					 | 
				
			||||||
	syncFrequency      = flag.Duration("sync_frequency", 10*time.Second, "Max period between synchronizing running containers and config")
 | 
						syncFrequency      = flag.Duration("sync_frequency", 10*time.Second, "Max period between synchronizing running containers and config")
 | 
				
			||||||
	fileCheckFrequency = flag.Duration("file_check_frequency", 20*time.Second, "Duration between checking config files for new data")
 | 
						fileCheckFrequency = flag.Duration("file_check_frequency", 20*time.Second, "Duration between checking config files for new data")
 | 
				
			||||||
	httpCheckFrequency = flag.Duration("http_check_frequency", 20*time.Second, "Duration between checking http for new data")
 | 
						httpCheckFrequency = flag.Duration("http_check_frequency", 20*time.Second, "Duration between checking http for new data")
 | 
				
			||||||
@@ -46,8 +45,13 @@ var (
 | 
				
			|||||||
	port               = flag.Uint("port", 10250, "The port for the info server to serve on")
 | 
						port               = flag.Uint("port", 10250, "The port for the info server to serve on")
 | 
				
			||||||
	hostnameOverride   = flag.String("hostname_override", "", "If non-empty, will use this string as identification instead of the actual hostname.")
 | 
						hostnameOverride   = flag.String("hostname_override", "", "If non-empty, will use this string as identification instead of the actual hostname.")
 | 
				
			||||||
	dockerEndpoint     = flag.String("docker_endpoint", "", "If non-empty, use this for the docker endpoint to communicate with")
 | 
						dockerEndpoint     = flag.String("docker_endpoint", "", "If non-empty, use this for the docker endpoint to communicate with")
 | 
				
			||||||
 | 
						etcdServerList     util.StringList
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getDockerEndpoint() string {
 | 
					func getDockerEndpoint() string {
 | 
				
			||||||
	var endpoint string
 | 
						var endpoint string
 | 
				
			||||||
	if len(*dockerEndpoint) > 0 {
 | 
						if len(*dockerEndpoint) > 0 {
 | 
				
			||||||
@@ -96,5 +100,5 @@ func main() {
 | 
				
			|||||||
		SyncFrequency:      *syncFrequency,
 | 
							SyncFrequency:      *syncFrequency,
 | 
				
			||||||
		HTTPCheckFrequency: *httpCheckFrequency,
 | 
							HTTPCheckFrequency: *httpCheckFrequency,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	k.RunKubelet(*dockerEndpoint, *config, *manifestURL, *etcdServers, *address, *port)
 | 
						k.RunKubelet(*dockerEndpoint, *config, *manifestURL, etcdServerList, *address, *port)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,10 +27,14 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	configFile  = flag.String("configfile", "/tmp/proxy_config", "Configuration file for the proxy")
 | 
						configFile     = flag.String("configfile", "/tmp/proxy_config", "Configuration file for the proxy")
 | 
				
			||||||
	etcdServers = flag.String("etcd_servers", "http://10.240.10.57:4001", "Servers for the etcd cluster (http://ip:port).")
 | 
						etcdServerList util.StringList
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
	flag.Parse()
 | 
						flag.Parse()
 | 
				
			||||||
	util.InitLogs()
 | 
						util.InitLogs()
 | 
				
			||||||
@@ -39,13 +43,13 @@ func main() {
 | 
				
			|||||||
	// Set up logger for etcd client
 | 
						// Set up logger for etcd client
 | 
				
			||||||
	etcd.SetLogger(util.NewLogger("etcd "))
 | 
						etcd.SetLogger(util.NewLogger("etcd "))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	glog.Infof("Using configuration file %s and etcd_servers %s", *configFile, *etcdServers)
 | 
						glog.Infof("Using configuration file %s and etcd_servers %v", *configFile, etcdServerList)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	serviceConfig := config.NewServiceConfig()
 | 
						serviceConfig := config.NewServiceConfig()
 | 
				
			||||||
	endpointsConfig := config.NewEndpointsConfig()
 | 
						endpointsConfig := config.NewEndpointsConfig()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Create a configuration source that handles configuration from etcd.
 | 
						// Create a configuration source that handles configuration from etcd.
 | 
				
			||||||
	etcdClient := etcd.NewClient([]string{*etcdServers})
 | 
						etcdClient := etcd.NewClient(etcdServerList)
 | 
				
			||||||
	config.NewConfigSourceEtcd(etcdClient,
 | 
						config.NewConfigSourceEtcd(etcdClient,
 | 
				
			||||||
		serviceConfig.Channel("etcd"),
 | 
							serviceConfig.Channel("etcd"),
 | 
				
			||||||
		endpointsConfig.Channel("etcd"))
 | 
							endpointsConfig.Channel("etcd"))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -93,7 +93,7 @@ const (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// RunKubelet starts background goroutines. If config_path, manifest_url, or address are empty,
 | 
					// RunKubelet starts background goroutines. If config_path, manifest_url, or address are empty,
 | 
				
			||||||
// they are not watched. Never returns.
 | 
					// they are not watched. Never returns.
 | 
				
			||||||
func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL, etcdServers, address string, port uint) {
 | 
					func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL string, etcdServers []string, address string, port uint) {
 | 
				
			||||||
	if kl.CadvisorClient == nil {
 | 
						if kl.CadvisorClient == nil {
 | 
				
			||||||
		var err error
 | 
							var err error
 | 
				
			||||||
		kl.CadvisorClient, err = cadvisor.NewClient("http://127.0.0.1:5000")
 | 
							kl.CadvisorClient, err = cadvisor.NewClient("http://127.0.0.1:5000")
 | 
				
			||||||
@@ -119,10 +119,9 @@ func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL, etcdServe
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}, kl.HTTPCheckFrequency)
 | 
							}, kl.HTTPCheckFrequency)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if etcdServers != "" {
 | 
						if len(etcdServers) > 0 {
 | 
				
			||||||
		servers := []string{etcdServers}
 | 
							glog.Infof("Watching for etcd configs at %v", etcdServers)
 | 
				
			||||||
		glog.Infof("Watching for etcd configs at %v", servers)
 | 
							kl.EtcdClient = etcd.NewClient(etcdServers)
 | 
				
			||||||
		kl.EtcdClient = etcd.NewClient(servers)
 | 
					 | 
				
			||||||
		go util.Forever(func() { kl.SyncAndSetupEtcdWatch(updateChannel) }, 20*time.Second)
 | 
							go util.Forever(func() { kl.SyncAndSetupEtcdWatch(updateChannel) }, 20*time.Second)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if address != "" {
 | 
						if address != "" {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user