Skip to content

Commit

Permalink
etcdmain: add separate 'acurl' field on user-provided flag
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Mar 1, 2017
1 parent 331946f commit a8b8cd9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions etcdmain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/coreos/etcd/embed"
"github.com/coreos/etcd/pkg/flags"
"github.com/coreos/etcd/pkg/types"
"github.com/coreos/etcd/version"
"github.com/ghodss/yaml"
)
Expand Down Expand Up @@ -79,6 +80,11 @@ type config struct {
printVersion bool
ignored []string
logOutput string

// needs this separate field in order to decide
// whether user provides its own url and prevents
// it from being overwritten by the default host
acurl string
}

// configFlags has the set of flags used for command line parsing a Config
Expand Down Expand Up @@ -141,7 +147,12 @@ func newConfig() *config {

// clustering
fs.Var(flags.NewURLsValue(embed.DefaultInitialAdvertisePeerURLs), "initial-advertise-peer-urls", "List of this member's peer URLs to advertise to the rest of the cluster.")
fs.Var(flags.NewURLsValue(embed.DefaultAdvertiseClientURLs), "advertise-client-urls", "List of this member's client URLs to advertise to the public.")
acflag := "List of this member's client URLs to advertise to the public"
if embed.DefaultAdvertiseClientURLs != "" {
acflag += fmt.Sprintf(" (if empty, defaults to %q)", embed.DefaultAdvertiseClientURLs)
}
acflag += "."
fs.StringVar(&cfg.acurl, "advertise-client-urls", "", acflag)
fs.StringVar(&cfg.Durl, "discovery", cfg.Durl, "Discovery URL used to bootstrap the cluster.")
fs.Var(cfg.fallback, "discovery-fallback", fmt.Sprintf("Valid values include %s", strings.Join(cfg.fallback.Values, ", ")))
if err := cfg.fallback.Set(fallbackFlagProxy); err != nil {
Expand Down Expand Up @@ -253,7 +264,15 @@ func (cfg *config) configFromCmdLine() error {
cfg.LPUrls = flags.URLsFromFlag(cfg.FlagSet, "listen-peer-urls")
cfg.APUrls = flags.URLsFromFlag(cfg.FlagSet, "initial-advertise-peer-urls")
cfg.LCUrls = flags.URLsFromFlag(cfg.FlagSet, "listen-client-urls")
cfg.ACUrls = flags.URLsFromFlag(cfg.FlagSet, "advertise-client-urls")
addr := cfg.acurl
if cfg.acurl == "" {
addr = embed.DefaultAdvertiseClientURLs
}
us, err := types.NewURLs(strings.Split(addr, ","))
if err != nil {
plog.Panicf("unexpected error parsing advertise-client-urls flag: %v", err)
}
cfg.ACUrls = us
cfg.ClusterState = cfg.clusterState.String()
cfg.Fallback = cfg.fallback.String()
cfg.Proxy = cfg.proxy.String()
Expand Down
2 changes: 1 addition & 1 deletion etcdmain/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func startEtcdOrProxyV2() {
GoMaxProcs := runtime.GOMAXPROCS(0)
plog.Infof("setting maximum number of CPUs to %d, total number of available CPUs is %d", GoMaxProcs, runtime.NumCPU())

(&cfg.Config).UpdateDefaultClusterFromName(defaultInitialCluster)
(&cfg.Config).UpdateDefaultClusterFromName(cfg.acurl, defaultInitialCluster)

if cfg.Dir == "" {
cfg.Dir = fmt.Sprintf("%v.etcd", cfg.Name)
Expand Down

0 comments on commit a8b8cd9

Please sign in to comment.