Skip to content

Commit

Permalink
Merge pull request #1092 from hashicorp/service-no-port
Browse files Browse the repository at this point in the history
Allowing registration of services which don't expose any ports
  • Loading branch information
dadgar committed Apr 14, 2016
2 parents 6e609fc + 1b8e663 commit a5e9620
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions client/consul/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,21 +295,20 @@ func (c *ConsulService) createCheckReg(check *structs.ServiceCheck, service *con

// createService creates a Consul AgentService from a Nomad Service
func (c *ConsulService) createService(service *structs.Service) (*consul.AgentService, error) {
host, port := c.task.FindHostAndPortFor(service.PortLabel)
if host == "" {
return nil, fmt.Errorf("host for the service %q couldn't be found", service.Name)
}

if port == 0 {
return nil, fmt.Errorf("port for the service %q couldn't be found", service.Name)
}
srv := consul.AgentService{
ID: service.ID(c.allocID, c.task.Name),
Service: service.Name,
Tags: service.Tags,
Address: host,
Port: port,
}
host, port := c.task.FindHostAndPortFor(service.PortLabel)
if host != "" {
srv.Address = host
}

if port != 0 {
srv.Port = port
}

return &srv, nil
}

Expand Down

0 comments on commit a5e9620

Please sign in to comment.