alphagov/vcloud-edge_gateway — pull request #61 by mattbostock (2014-05-13 12:45:39+00:00)
Title: [#71128590] Don't set healthcheck URI for non-HTTP checks

Don't set a healthcheck URI for non-HTTP load balancer healthchecks.

In vCloud Director version 5.1 and 5.5, VMWare does not support a
healthcheck URI for SSL healthchecks[1]. In vCloud Director version 5.5,
a load balancer will refuse connections if a health check URL is set for
an SSL healthcheck.

TCP healthchecks obviously do not support a healthcheck URI given they
do not operate at layer 7.

This also fixes an issue related to ecfba39; that commit checks for a pool
service protocol of HTTP and sets the healthcheck URL accordingly. The
changes there did not however account for configurations where the pool
uses HTTP as the service protocol but TCP for the healthcheck.

Note that we check twice for the HTTP protocol. The first time [2]
when we assume that the healthcheck protocol is the same as the service
protocol; the second time[3] when we know what protocol has been defined
for the healthcheck (if any). It's necessary to check twice in case the
`input_pool_healthcheck_entry` array is `nil`, which can occur if no
'health_check' directive has been defined in the configuration file[4].

The logic here is necessarily complex because we deal with:
- defined configuration versus the default
- healthcheck protocols (default or defined) versus service protocols

Raise an exception if a healthcheck URI is specified for a load
balancer healthcheck using any protocol other than HTTP.

Also adds tests for the above behaviour:

- Add a spec test to ensure that that the default URI for healthchecks
is '/' for HTTP healthchecks. The behaviour we are testing for was
implemented in e9c524b.

- Add a spec test that expects an exception to be raised if we attempt
to define a healthcheck URI for a non-HTTP healthcheck. Only HTTP
healthchecks support a healthcheck URI.

[1]:
http://pubs.vmware.com/vcd-55/topic/com.vmware.vcloud.admin.doc_55/GUID-C12B3954-155F-48AF-9855-E0DE026752D0.html
[2]:
https://github.com/alphagov/vcloud-edge_gateway/blob/cb3d688e8727d3995acacf33e274697f35ae4aff/lib/vcloud/edge_gateway/configuration_generator/load_balancer_service.rb#L186
[3]:
https://github.com/alphagov/vcloud-edge_gateway/blob/cb3d688e8727d3995acacf33e274697f35ae4aff/lib/vcloud/edge_gateway/configuration_generator/load_balancer_service.rb#L196-L200
[4]:
https://github.com/alphagov/vcloud-edge_gateway/blob/cb3d688e8727d3995acacf33e274697f35ae4aff/lib/vcloud/edge_gateway/configuration_generator/load_balancer_service.rb#L174-L178