Re: Problem with string negation in httpcheck-expect

2015-01-27 Thread Cyril Bonté

Hi Sébastien,

Le 27/01/2015 10:43, Sébastien ROHAUT a écrit :

To complete my answer, All of theses are working :
- Adding Connection: close header
- Moving to HTTP/1.0
- set the keepalive timeout to 0 in webserver configuration

HTTP/1.0 is not the best solution, because some webservers (jetty...)
return a Connection: keep-alive, as it's supported by the protocol.

But, the best thing to do should be to modify the way haproxy get the
content (for the health check) : check for the Content-Length, which is
the best solution.


OK thanks for your feedback.
Please keep the mailing list in CC when you reply ;-)




2015-01-27 7:22 GMT+01:00 Sébastien ROHAUT
mailto:sebastien.rohaut@gmail.com>>:

Cyril, we found the answer at the same time ! This is the keepalive.
And yes I think the doc should be updated.
It works if in my nginx configuration I disable keepalive for this
url or if I use http 1.0.

thank you

Sebastien

Le 26 janv. 2015 23:25, "Cyril Bonté" mailto:cyril.bo...@free.fr>> a écrit :

Hi Sébastien and Baptiste,

Le 26/01/2015 23:12, Baptiste a écrit :


Le 26 janv. 2015 13:43, "Sébastien ROHAUT"
mailto:sebastien.rohaut@gmail.com>
>>
a écrit :
  >  (...)
  > For the http-check, we want to test the value of
"healthStatus",
which can be "Healthy", "Unhealthy", "DegradedMode". Our
server must be
put out of the backend only if value is ""Unhealthy". So, we
tried this :
  >
  > http-check expect ! string "healthStatus":"Unhealthy"
  >
  > But it doesn't work as expected.
  > (...)

What does your option httpchk look like?


I was just making some tests.
I think this is happening because the buffer is not full and the
server didn't close the connection, which happens when the
server is using keep-alive.
As checks don't handle the HTTP connection type, haproxy is
waiting fore more data until a timeout occurs.

Sébastien, in order to prevent keep-alive, you should try with
one of this solution in your httpchk line :
- use HTTP/1.0
- or append \r\nConnection:\ close

Maybe this is something we should consider to add in the
documentation, or we can try to parse HTTP headers for a
Content-Length header or for chunks (it might require a lot of
work).
Or maybe we can transparently add the "Connection: close" header
to any http check sent from haproxy.

--
Cyril Bonté





--
Cyril Bonté



Re: Problem with string negation in httpcheck-expect

2015-01-26 Thread Cyril Bonté

Hi Sébastien and Baptiste,

Le 26/01/2015 23:12, Baptiste a écrit :


Le 26 janv. 2015 13:43, "Sébastien ROHAUT"
mailto:sebastien.rohaut@gmail.com>>
a écrit :
 >  (...)
 > For the http-check, we want to test the value of  "healthStatus",
which can be "Healthy", "Unhealthy", "DegradedMode". Our server must be
put out of the backend only if value is ""Unhealthy". So, we tried this :
 >
 > http-check expect ! string "healthStatus":"Unhealthy"
 >
 > But it doesn't work as expected.
 > (...)

What does your option httpchk look like?


I was just making some tests.
I think this is happening because the buffer is not full and the server 
didn't close the connection, which happens when the server is using 
keep-alive.
As checks don't handle the HTTP connection type, haproxy is waiting fore 
more data until a timeout occurs.


Sébastien, in order to prevent keep-alive, you should try with one of 
this solution in your httpchk line :

- use HTTP/1.0
- or append \r\nConnection:\ close

Maybe this is something we should consider to add in the documentation, 
or we can try to parse HTTP headers for a Content-Length header or for 
chunks (it might require a lot of work).
Or maybe we can transparently add the "Connection: close" header to any 
http check sent from haproxy.


--
Cyril Bonté



Re: Problem with string negation in httpcheck-expect

2015-01-26 Thread Baptiste
Le 26 janv. 2015 13:43, "Sébastien ROHAUT" 
a écrit :
>
> Hi,
>
> We're encountering a problem with a http-check expect ! string. here is a
sample of our check url :
>
> {
>   "hostname":"toto",
>   "type":"backend",
>   "isHealthy":true,
>   "healthStatus":"Healthy",
>   "healthyServices":2,
>   "unhealthyServices":0,
>   "services":[{
> "name":"Elasticsearch",
> "isServiceHealthy":true,
> "serviceHealthStatus":"Healthy",
> "message":"ES Cluster status is GREEN"
>   },{
> "name":"ZooKeeper",
> "isServiceHealthy":true,
> "serviceHealthStatus":"Healthy",
> "message":"ZK Cluster is available"
>   }],
>   "belisariusRelease":"96"
> }
>
> For the http-check, we want to test the value of  "healthStatus", which
can be "Healthy", "Unhealthy", "DegradedMode". Our server must be put out
of the backend only if value is ""Unhealthy". So, we tried this :
>
> http-check expect ! string "healthStatus":"Unhealthy"
>
> But it doesn't work as expected. In fact, whatever we put, if we use
negation (we didn't tried with something else than string), it doesn't
work. We event tried with "toto" (which we be never here), it's the same :
the server is always excluded from the backend's pool.
>
> At the end, we used to put a rstring :
>
> http-check expect  rstring "healthStatus":"(Healthy|DegradedMode)"
>
> and it seems to work.
>
> What is the problem ? Are we doing something bad, or perhaps we don't
understand the meaning of the negation ?
>
> Thank you for your help.
>
> Sébastien Rohaut
>

Hi,

What does your option httpchk look like?

Baptiste


Problem with string negation in httpcheck-expect

2015-01-26 Thread Sébastien ROHAUT
Hi,

We're encountering a problem with a http-check expect ! string. here is a
sample of our check url :

{
  "hostname":"toto",
  "type":"backend",
  "isHealthy":true,
  "healthStatus":"Healthy",
  "healthyServices":2,
  "unhealthyServices":0,
  "services":[{
"name":"Elasticsearch",
"isServiceHealthy":true,
"serviceHealthStatus":"Healthy",
"message":"ES Cluster status is GREEN"
  },{
"name":"ZooKeeper",
"isServiceHealthy":true,
"serviceHealthStatus":"Healthy",
"message":"ZK Cluster is available"
  }],
  "belisariusRelease":"96"
}

For the http-check, we want to test the value of  "healthStatus", which can
be "Healthy", "Unhealthy", "DegradedMode". Our server must be put out of
the backend only if value is ""Unhealthy". So, we tried this :

http-check expect ! string "healthStatus":"Unhealthy"

But it doesn't work as expected. In fact, whatever we put, if we use
negation (we didn't tried with something else than string), it doesn't
work. We event tried with "toto" (which we be never here), it's the same :
the server is always excluded from the backend's pool.

At the end, we used to put a rstring :

http-check expect  rstring "healthStatus":"(Healthy|DegradedMode)"

and it seems to work.

What is the problem ? Are we doing something bad, or perhaps we don't
understand the meaning of the negation ?

Thank you for your help.

Sébastien Rohaut