Skip to content

Commit 1ae9b66

Browse files
author
Matthew
committed
fix(publisher): ignore healthcheck values if unset
publisher would do a lazy check and convert the etcd keys to an integer. However, these keys are optional, so if they are unset, an empty string would be returned from getEtcd(). By explicitly checking if the keys are set, this will circumvent the strconv errors.
1 parent 05afd5c commit 1ae9b66

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

publisher/server/publisher.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ func (s *Server) publishContainer(container *docker.APIContainers, ttl time.Dura
111111
appPath := fmt.Sprintf("%s/%s", appName, containerName)
112112
keyPath := fmt.Sprintf("/deis/services/%s", appPath)
113113
for _, p := range container.Ports {
114+
var delay int
115+
var timeout int
116+
var err error
114117
// lowest port wins (docker sorts the ports)
115118
// TODO (bacongobbler): support multiple exposed ports
116119
port := strconv.Itoa(int(p.PublicPort))
@@ -119,14 +122,24 @@ func (s *Server) publishContainer(container *docker.APIContainers, ttl time.Dura
119122
configKey := fmt.Sprintf("/deis/config/%s/", appName)
120123
// check if the user specified a healthcheck URL
121124
healthcheckURL := s.getEtcd(configKey + "healthcheck_url")
122-
delay, err := strconv.Atoi(s.getEtcd(configKey + "healthcheck_initial_delay"))
123-
if err != nil {
124-
log.Println(err)
125+
initialDelay := s.getEtcd(configKey + "healthcheck_initial_delay")
126+
if initialDelay != "" {
127+
delay, err = strconv.Atoi(initialDelay)
128+
if err != nil {
129+
log.Println(err)
130+
delay = 0
131+
}
132+
} else {
125133
delay = 0
126134
}
127-
timeout, err := strconv.Atoi(s.getEtcd(configKey + "healthcheck_timeout"))
128-
if err != nil {
129-
log.Println(err)
135+
healthcheckTimeout := s.getEtcd(configKey + "healthcheck_timeout")
136+
if healthcheckTimeout != "" {
137+
timeout, err = strconv.Atoi(healthcheckTimeout)
138+
if err != nil {
139+
log.Println(err)
140+
timeout = 1
141+
}
142+
} else {
130143
timeout = 1
131144
}
132145
if healthcheckURL != "" {

0 commit comments

Comments
 (0)