Skip to content

Commit

Permalink
Fix passHealthCheck breaking on Consul >= 1.0.
Browse files Browse the repository at this point in the history
See added comment.

Fixes test suite failure:

    testRunServiceTtl:           FAIL (15.01s)
      tests/Main.hs:323:
      testRunServiceTtl: Check not passing

that creates consul log messsage:

    [ERR] http: Request GET /v1/agent/check/pass/service:testRunServiceTtl, error: method GET not allowed
  • Loading branch information
nh2 committed Jul 13, 2019
1 parent 37a1a1b commit da899d0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Network/Consul/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,17 @@ deregisterHealthCheck manager hostname portNumber checkId = do

passHealthCheck :: MonadIO m => Manager -> Text -> PortNumber -> Text -> Maybe Datacenter -> m ()
passHealthCheck manager hostname portNumber checkId dc = do
initReq <- createRequest hostname portNumber (T.concat ["/v1/agent/check/pass/", checkId]) Nothing Nothing False dc
-- Using `Just ""` as the `body` to ensure a PUT request is used.
-- Consul < 1.0 accepted a GET here (which was a legacy mistake).
-- In 1.0, they switched it to require a PUT.
-- See also:
-- * https://github.com/hashicorp/consul/issues/3659
-- * https://github.com/cablehead/python-consul/pull/182
-- * https://github.com/hashicorp/consul/blob/51ea240df8476e02215d53fbfad5838bf0d44d21/CHANGELOG.md
-- Section "HTTP Verbs are Enforced in Many HTTP APIs":
-- > Many endpoints in the HTTP API that previously took any HTTP verb
-- > now check for specific HTTP verbs and enforce them.
initReq <- createRequest hostname portNumber (T.concat ["/v1/agent/check/pass/", checkId]) Nothing (Just "") False dc
liftIO $ withResponse initReq manager $ \ response -> do
return ()

Expand Down

0 comments on commit da899d0

Please sign in to comment.