Skip to content

Commit

Permalink
mistake in health-check was always returning unhealthy or errored out…
Browse files Browse the repository at this point in the history
… on connection issue
  • Loading branch information
TimoKramer committed Feb 26, 2020
1 parent f9577df commit e939327
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
16 changes: 9 additions & 7 deletions src/bob/api/health.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
"Check the systems we depend upon. Returns nil if everything is alright, else returns a sequence
of strings naming the failing systems."
[]
(let [docker (when (f/failed? (f/try* (docker/invoke states/ping {:op :SystemPing})))
["Docker"])
postgres (when (f/failed? (f/try* (db-health-check states/db)))
["Postgres"])
extsys (when (nil? postgres)
(ping-external-systems))]
(let [ping-client (docker/client {:category :_ping
:conn (docker/connect {:uri "unix:///var/run/docker.sock"})})
docker (when (not (= "OK" (docker/invoke ping-client {:op :SystemPing})))
["Docker"])
postgres (when (f/failed? (f/try* (db-health-check states/db)))
["Postgres"])
extsys (when (nil? postgres)
(ping-external-systems))]
(filter some? (concat docker postgres extsys))))

(defn respond-to-health-check
Expand Down Expand Up @@ -96,7 +98,7 @@

(ping-external-systems)

(str "Health check failed: " (clojure.string/join " and " (health-check)) " not healthy")
(health-check)

(log-health-check)

Expand Down
9 changes: 1 addition & 8 deletions src/bob/states.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,14 @@
:start (repl/migrate migration-config))

(m/defstate docker-conn
:start (docker/connect {:uri "unix:///var/run/docker.sock"
:connect-timeout 10
:read-timeout 2000
:write-timeout 2000
:call-timeout 30000}))
:start (docker/connect {:uri "unix:///var/run/docker.sock"}))

(m/defstate images
:start (docker/client {:category :images :conn docker-conn}))

(m/defstate containers
:start (docker/client {:category :containers :conn docker-conn}))

(m/defstate ping
:start (docker/client {:category :_ping :conn docker-conn}))

(m/defstate commit
:start (docker/client {:category :commit :conn docker-conn}))

Expand Down

0 comments on commit e939327

Please sign in to comment.