Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vault-driven Consul TTL checks #1349

Merged
merged 21 commits into from
Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion command/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ func LoadConfig(path string) (*DefaultConfig, error) {
path = v
}

// NOTE: requires HOME env var to be set
path, err := homedir.Expand(path)
if err != nil {
return nil, fmt.Errorf("Error expanding config path: %s", err)
return nil, fmt.Errorf("Error expanding config path %s: %s", path, err)
}

contents, err := ioutil.ReadFile(path)
Expand Down
13 changes: 12 additions & 1 deletion command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (c *ServerCommand) Run(args []string) int {
coreConfig.AdvertiseAddr = envAA
}

// Attempt to detect the advertise address possible
// Attempt to detect the advertise address, if possible
var detect physical.AdvertiseDetect
if coreConfig.HAPhysical != nil {
detect, ok = coreConfig.HAPhysical.(physical.AdvertiseDetect)
Expand Down Expand Up @@ -286,6 +286,17 @@ func (c *ServerCommand) Run(args []string) int {
}
}

// If the backend supports service discovery, run service discovery
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional minor comment. If this block is around line 225, before core is initialized, I felt that it would be easy to understand the flow. Up to you :)

if coreConfig.HAPhysical != nil {
sd, ok := coreConfig.HAPhysical.(physical.ServiceDiscovery)
if ok {
if err := sd.RunServiceDiscovery(c.ShutdownCh, coreConfig.AdvertiseAddr); err != nil {
c.Ui.Error(fmt.Sprintf("Error initializing service discovery: %v", err))
return 1
}
}
}

// Initialize the listeners
lns := make([]net.Listener, 0, len(config.Listeners))
for i, lnConfig := range config.Listeners {
Expand Down
4 changes: 2 additions & 2 deletions command/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func parseBackends(result *Config, list *ast.ObjectList) error {
return multierror.Prefix(err, fmt.Sprintf("backend.%s:", key))
}

// Pull out the advertise address since it's commong to all backends
// Pull out the advertise address since it's common to all backends
var advertiseAddr string
if v, ok := m["advertise_addr"]; ok {
advertiseAddr = v
Expand Down Expand Up @@ -398,7 +398,7 @@ func parseHABackends(result *Config, list *ast.ObjectList) error {
return multierror.Prefix(err, fmt.Sprintf("ha_backend.%s:", key))
}

// Pull out the advertise address since it's commong to all backends
// Pull out the advertise address since it's common to all backends
var advertiseAddr string
if v, ok := m["advertise_addr"]; ok {
advertiseAddr = v
Expand Down
6 changes: 4 additions & 2 deletions command/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ listener "tcp" {
consulhcl = `
backend "consul" {
prefix = "foo/"
advertise_addr = "http://127.0.0.1:8200"
advertise_addr = "http://127.0.0.1:8200"
disable_registration = "true"
}
`
haconsulhcl = `
ha_backend "consul" {
prefix = "bar/"
advertise_addr = "http://127.0.0.1:8200"
advertise_addr = "http://127.0.0.1:8200"
disable_registration = "true"
}
`

Expand Down
Loading