GCP Bug Fixes (#48276)

* GCP Bug fixes

* added util file changes
This commit is contained in:
Alex Stephen 2018-11-15 05:44:10 -08:00
parent 5c97cc1da0
commit d64785e811
80 changed files with 14198 additions and 13862 deletions

View file

@ -32,214 +32,229 @@ DOCUMENTATION = '''
---
module: gcp_compute_health_check
description:
- Health Checks determine whether instances are responsive and able to do work.
- They are an important part of a comprehensive load balancing configuration, as they
enable monitoring instances behind load balancers.
- Health Checks poll instances at a specified interval. Instances that do not respond
successfully to some number of probes in a row are marked as unhealthy. No new connections
are sent to unhealthy instances, though existing connections will continue. The
health check will continue to poll unhealthy instances. If an instance later responds
successfully to some number of consecutive probes, it is marked healthy again and
can receive new connections.
- Health Checks determine whether instances are responsive and able to do work.
- They are an important part of a comprehensive load balancing configuration, as they
enable monitoring instances behind load balancers.
- Health Checks poll instances at a specified interval. Instances that do not respond
successfully to some number of probes in a row are marked as unhealthy. No new connections
are sent to unhealthy instances, though existing connections will continue. The
health check will continue to poll unhealthy instances. If an instance later responds
successfully to some number of consecutive probes, it is marked healthy again and
can receive new connections.
short_description: Creates a GCP HealthCheck
version_added: 2.6
author: Google Inc. (@googlecloudplatform)
requirements:
- python >= 2.6
- requests >= 2.18.4
- google-auth >= 1.3.0
- python >= 2.6
- requests >= 2.18.4
- google-auth >= 1.3.0
options:
state:
description:
- Whether the given object should exist in GCP
choices: ['present', 'absent']
default: 'present'
check_interval_sec:
description:
- How often (in seconds) to send a health check. The default value is 5 seconds.
required: false
default: 5
state:
description:
- Whether the given object should exist in GCP
choices:
- present
- absent
default: present
check_interval_sec:
description:
- How often (in seconds) to send a health check. The default value is 5 seconds.
required: false
default: '5'
description:
description:
- An optional description of this resource. Provide this property when you create
the resource.
required: false
healthy_threshold:
description:
- A so-far unhealthy instance will be marked healthy after this many consecutive
successes. The default value is 2.
required: false
default: '2'
name:
description:
- Name of the resource. Provided by the client when the resource is created. The
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
which means the first character must be a lowercase letter, and all following
characters must be a dash, lowercase letter, or digit, except the last character,
which cannot be a dash.
required: true
timeout_sec:
description:
- How long (in seconds) to wait before claiming failure.
- The default value is 5 seconds. It is invalid for timeoutSec to have greater
value than checkIntervalSec.
required: false
default: '5'
aliases:
- timeout_seconds
unhealthy_threshold:
description:
- A so-far healthy instance will be marked unhealthy after this many consecutive
failures. The default value is 2.
required: false
default: '2'
type:
description:
- Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not
specified, the default is TCP. Exactly one of the protocol-specific health check
field must be specified, which must match type field.
required: false
choices:
- TCP
- SSL
- HTTP
- HTTPS
http_health_check:
description:
- A nested object resource.
required: false
suboptions:
host:
description:
- An optional description of this resource. Provide this property when you create
the resource.
- The value of the host header in the HTTP health check request.
- If left empty (default value), the public IP on behalf of which this health
check is performed will be used.
required: false
healthy_threshold:
request_path:
description:
- A so-far unhealthy instance will be marked healthy after this many consecutive successes.
The default value is 2.
- The request path of the HTTP health check request.
- The default value is /.
required: false
default: 2
name:
default: "/"
port:
description:
- Name of the resource. Provided by the client when the resource is created. The name
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
which means the first character must be a lowercase letter, and all following characters
must be a dash, lowercase letter, or digit, except the last character, which cannot
be a dash.
required: true
timeout_sec:
description:
- How long (in seconds) to wait before claiming failure.
- The default value is 5 seconds. It is invalid for timeoutSec to have greater value
than checkIntervalSec.
- The TCP port number for the HTTP health check request.
- The default value is 80.
required: false
default: 5
aliases: [timeout_seconds]
unhealthy_threshold:
port_name:
description:
- A so-far healthy instance will be marked unhealthy after this many consecutive failures.
The default value is 2.
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
default: 2
type:
proxy_header:
description:
- Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not specified,
the default is TCP. Exactly one of the protocol-specific health check field must
be specified, which must match type field.
- Specifies the type of proxy header to append before sending data to the
backend, either NONE or PROXY_V1. The default is NONE.
required: false
choices: ['TCP', 'SSL', 'HTTP', 'HTTPS']
http_health_check:
default: NONE
choices:
- NONE
- PROXY_V1
https_health_check:
description:
- A nested object resource.
required: false
suboptions:
host:
description:
- A nested object resource.
- The value of the host header in the HTTPS health check request.
- If left empty (default value), the public IP on behalf of which this health
check is performed will be used.
required: false
suboptions:
host:
description:
- The value of the host header in the HTTP health check request.
- If left empty (default value), the public IP on behalf of which this health check
is performed will be used.
required: false
request_path:
description:
- The request path of the HTTP health check request.
- The default value is /.
required: false
default: /
port:
description:
- The TCP port number for the HTTP health check request.
- The default value is 80.
required: false
port_name:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
proxy_header:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
required: false
default: NONE
choices: ['NONE', 'PROXY_V1']
https_health_check:
request_path:
description:
- A nested object resource.
- The request path of the HTTPS health check request.
- The default value is /.
required: false
suboptions:
host:
description:
- The value of the host header in the HTTPS health check request.
- If left empty (default value), the public IP on behalf of which this health check
is performed will be used.
required: false
request_path:
description:
- The request path of the HTTPS health check request.
- The default value is /.
required: false
default: /
port:
description:
- The TCP port number for the HTTPS health check request.
- The default value is 443.
required: false
port_name:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
proxy_header:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
required: false
default: NONE
choices: ['NONE', 'PROXY_V1']
tcp_health_check:
default: "/"
port:
description:
- A nested object resource.
- The TCP port number for the HTTPS health check request.
- The default value is 443.
required: false
suboptions:
request:
description:
- The application data to send once the TCP connection has been established (default
value is empty). If both request and response are empty, the connection establishment
alone will indicate health. The request data can only be ASCII.
required: false
response:
description:
- The bytes to match against the beginning of the response data. If left empty (the
default value), any response will indicate health. The response data can only be
ASCII.
required: false
port:
description:
- The TCP port number for the TCP health check request.
- The default value is 443.
required: false
port_name:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
proxy_header:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
required: false
default: NONE
choices: ['NONE', 'PROXY_V1']
ssl_health_check:
port_name:
description:
- A nested object resource.
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
suboptions:
request:
description:
- The application data to send once the SSL connection has been established (default
value is empty). If both request and response are empty, the connection establishment
alone will indicate health. The request data can only be ASCII.
required: false
response:
description:
- The bytes to match against the beginning of the response data. If left empty (the
default value), any response will indicate health. The response data can only be
ASCII.
required: false
port:
description:
- The TCP port number for the SSL health check request.
- The default value is 443.
required: false
port_name:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
proxy_header:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
required: false
default: NONE
choices: ['NONE', 'PROXY_V1']
proxy_header:
description:
- Specifies the type of proxy header to append before sending data to the
backend, either NONE or PROXY_V1. The default is NONE.
required: false
default: NONE
choices:
- NONE
- PROXY_V1
tcp_health_check:
description:
- A nested object resource.
required: false
suboptions:
request:
description:
- The application data to send once the TCP connection has been established
(default value is empty). If both request and response are empty, the connection
establishment alone will indicate health. The request data can only be ASCII.
required: false
response:
description:
- The bytes to match against the beginning of the response data. If left empty
(the default value), any response will indicate health. The response data
can only be ASCII.
required: false
port:
description:
- The TCP port number for the TCP health check request.
- The default value is 443.
required: false
port_name:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
proxy_header:
description:
- Specifies the type of proxy header to append before sending data to the
backend, either NONE or PROXY_V1. The default is NONE.
required: false
default: NONE
choices:
- NONE
- PROXY_V1
ssl_health_check:
description:
- A nested object resource.
required: false
suboptions:
request:
description:
- The application data to send once the SSL connection has been established
(default value is empty). If both request and response are empty, the connection
establishment alone will indicate health. The request data can only be ASCII.
required: false
response:
description:
- The bytes to match against the beginning of the response data. If left empty
(the default value), any response will indicate health. The response data
can only be ASCII.
required: false
port:
description:
- The TCP port number for the SSL health check request.
- The default value is 443.
required: false
port_name:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
required: false
proxy_header:
description:
- Specifies the type of proxy header to append before sending data to the
backend, either NONE or PROXY_V1. The default is NONE.
required: false
default: NONE
choices:
- NONE
- PROXY_V1
extends_documentation_fragment: gcp
notes:
- "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/latest/healthChecks)"
- "Official Documentation: U(https://cloud.google.com/load-balancing/docs/health-checks)"
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/latest/healthChecks)'
- 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/health-checks)'
'''
EXAMPLES = '''
@ -261,213 +276,213 @@ EXAMPLES = '''
'''
RETURN = '''
checkIntervalSec:
description:
- How often (in seconds) to send a health check. The default value is 5 seconds.
returned: success
type: int
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
returned: success
type: str
description:
description:
- An optional description of this resource. Provide this property when you create
the resource.
returned: success
type: str
healthyThreshold:
description:
- A so-far unhealthy instance will be marked healthy after this many consecutive successes.
The default value is 2.
returned: success
type: int
id:
description:
- The unique identifier for the resource. This identifier is defined by the server.
returned: success
type: int
name:
description:
- Name of the resource. Provided by the client when the resource is created. The name
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
which means the first character must be a lowercase letter, and all following characters
must be a dash, lowercase letter, or digit, except the last character, which cannot
be a dash.
returned: success
type: str
timeoutSec:
description:
- How long (in seconds) to wait before claiming failure.
- The default value is 5 seconds. It is invalid for timeoutSec to have greater value
than checkIntervalSec.
returned: success
type: int
unhealthyThreshold:
description:
- A so-far healthy instance will be marked unhealthy after this many consecutive failures.
The default value is 2.
returned: success
type: int
type:
description:
- Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not specified,
the default is TCP. Exactly one of the protocol-specific health check field must
be specified, which must match type field.
returned: success
type: str
httpHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
host:
description:
- The value of the host header in the HTTP health check request.
- If left empty (default value), the public IP on behalf of which this health check
is performed will be used.
returned: success
type: str
requestPath:
description:
- The request path of the HTTP health check request.
- The default value is /.
returned: success
type: str
port:
description:
- The TCP port number for the HTTP health check request.
- The default value is 80.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
httpsHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
host:
description:
- The value of the host header in the HTTPS health check request.
- If left empty (default value), the public IP on behalf of which this health check
is performed will be used.
returned: success
type: str
requestPath:
description:
- The request path of the HTTPS health check request.
- The default value is /.
returned: success
type: str
port:
description:
- The TCP port number for the HTTPS health check request.
- The default value is 443.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
tcpHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
request:
description:
- The application data to send once the TCP connection has been established (default
value is empty). If both request and response are empty, the connection establishment
alone will indicate health. The request data can only be ASCII.
returned: success
type: str
response:
description:
- The bytes to match against the beginning of the response data. If left empty (the
default value), any response will indicate health. The response data can only be
ASCII.
returned: success
type: str
port:
description:
- The TCP port number for the TCP health check request.
- The default value is 443.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
sslHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
request:
description:
- The application data to send once the SSL connection has been established (default
value is empty). If both request and response are empty, the connection establishment
alone will indicate health. The request data can only be ASCII.
returned: success
type: str
response:
description:
- The bytes to match against the beginning of the response data. If left empty (the
default value), any response will indicate health. The response data can only be
ASCII.
returned: success
type: str
port:
description:
- The TCP port number for the SSL health check request.
- The default value is 443.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
checkIntervalSec:
description:
- How often (in seconds) to send a health check. The default value is 5 seconds.
returned: success
type: int
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
returned: success
type: str
description:
description:
- An optional description of this resource. Provide this property when you create
the resource.
returned: success
type: str
healthyThreshold:
description:
- A so-far unhealthy instance will be marked healthy after this many consecutive
successes. The default value is 2.
returned: success
type: int
id:
description:
- The unique identifier for the resource. This identifier is defined by the server.
returned: success
type: int
name:
description:
- Name of the resource. Provided by the client when the resource is created. The
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
which means the first character must be a lowercase letter, and all following
characters must be a dash, lowercase letter, or digit, except the last character,
which cannot be a dash.
returned: success
type: str
timeoutSec:
description:
- How long (in seconds) to wait before claiming failure.
- The default value is 5 seconds. It is invalid for timeoutSec to have greater value
than checkIntervalSec.
returned: success
type: int
unhealthyThreshold:
description:
- A so-far healthy instance will be marked unhealthy after this many consecutive
failures. The default value is 2.
returned: success
type: int
type:
description:
- Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not
specified, the default is TCP. Exactly one of the protocol-specific health check
field must be specified, which must match type field.
returned: success
type: str
httpHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
host:
description:
- The value of the host header in the HTTP health check request.
- If left empty (default value), the public IP on behalf of which this health
check is performed will be used.
returned: success
type: str
requestPath:
description:
- The request path of the HTTP health check request.
- The default value is /.
returned: success
type: str
port:
description:
- The TCP port number for the HTTP health check request.
- The default value is 80.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
httpsHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
host:
description:
- The value of the host header in the HTTPS health check request.
- If left empty (default value), the public IP on behalf of which this health
check is performed will be used.
returned: success
type: str
requestPath:
description:
- The request path of the HTTPS health check request.
- The default value is /.
returned: success
type: str
port:
description:
- The TCP port number for the HTTPS health check request.
- The default value is 443.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
tcpHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
request:
description:
- The application data to send once the TCP connection has been established
(default value is empty). If both request and response are empty, the connection
establishment alone will indicate health. The request data can only be ASCII.
returned: success
type: str
response:
description:
- The bytes to match against the beginning of the response data. If left empty
(the default value), any response will indicate health. The response data
can only be ASCII.
returned: success
type: str
port:
description:
- The TCP port number for the TCP health check request.
- The default value is 443.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
sslHealthCheck:
description:
- A nested object resource.
returned: success
type: complex
contains:
request:
description:
- The application data to send once the SSL connection has been established
(default value is empty). If both request and response are empty, the connection
establishment alone will indicate health. The request data can only be ASCII.
returned: success
type: str
response:
description:
- The bytes to match against the beginning of the response data. If left empty
(the default value), any response will indicate health. The response data
can only be ASCII.
returned: success
type: str
port:
description:
- The TCP port number for the SSL health check request.
- The default value is 443.
returned: success
type: int
portName:
description:
- Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
are defined, port takes precedence.
returned: success
type: str
proxyHeader:
description:
- Specifies the type of proxy header to append before sending data to the backend,
either NONE or PROXY_V1. The default is NONE.
returned: success
type: str
'''
################################################################################
@ -583,10 +598,10 @@ def resource_to_request(module):
u'timeoutSec': module.params.get('timeout_sec'),
u'unhealthyThreshold': module.params.get('unhealthy_threshold'),
u'type': module.params.get('type'),
u'httpHealthCheck': HealthCheckHttpHealthCheck(module.params.get('http_health_check', {}), module).to_request(),
u'httpsHealthCheck': HealthCheckHttpsHealthCheck(module.params.get('https_health_check', {}), module).to_request(),
u'tcpHealthCheck': HealthCheckTcpHealthCheck(module.params.get('tcp_health_check', {}), module).to_request(),
u'sslHealthCheck': HealthCheckSslHealthCheck(module.params.get('ssl_health_check', {}), module).to_request()
u'httpHealthCheck': HealthCheckHttphealthcheck(module.params.get('http_health_check', {}), module).to_request(),
u'httpsHealthCheck': HealthCheckHttpshealthcheck(module.params.get('https_health_check', {}), module).to_request(),
u'tcpHealthCheck': HealthCheckTcphealthcheck(module.params.get('tcp_health_check', {}), module).to_request(),
u'sslHealthCheck': HealthCheckSslhealthcheck(module.params.get('ssl_health_check', {}), module).to_request()
}
return_vals = {}
for k, v in request.items():
@ -661,10 +676,10 @@ def response_to_hash(module, response):
u'timeoutSec': response.get(u'timeoutSec'),
u'unhealthyThreshold': response.get(u'unhealthyThreshold'),
u'type': response.get(u'type'),
u'httpHealthCheck': HealthCheckHttpHealthCheck(response.get(u'httpHealthCheck', {}), module).from_response(),
u'httpsHealthCheck': HealthCheckHttpsHealthCheck(response.get(u'httpsHealthCheck', {}), module).from_response(),
u'tcpHealthCheck': HealthCheckTcpHealthCheck(response.get(u'tcpHealthCheck', {}), module).from_response(),
u'sslHealthCheck': HealthCheckSslHealthCheck(response.get(u'sslHealthCheck', {}), module).from_response()
u'httpHealthCheck': HealthCheckHttphealthcheck(response.get(u'httpHealthCheck', {}), module).from_response(),
u'httpsHealthCheck': HealthCheckHttpshealthcheck(response.get(u'httpsHealthCheck', {}), module).from_response(),
u'tcpHealthCheck': HealthCheckTcphealthcheck(response.get(u'tcpHealthCheck', {}), module).from_response(),
u'sslHealthCheck': HealthCheckSslhealthcheck(response.get(u'sslHealthCheck', {}), module).from_response()
}
@ -692,8 +707,6 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], 'message')
time.sleep(1.0)
if status not in ['PENDING', 'RUNNING', 'DONE']:
module.fail_json(msg="Invalid result %s" % status)
op_result = fetch_resource(module, op_uri, 'compute#operation')
status = navigate_hash(op_result, ['status'])
return op_result
@ -705,7 +718,7 @@ def raise_if_errors(response, err_path, module):
module.fail_json(msg=errors)
class HealthCheckHttpHealthCheck(object):
class HealthCheckHttphealthcheck(object):
def __init__(self, request, module):
self.module = module
if request:
@ -732,7 +745,7 @@ class HealthCheckHttpHealthCheck(object):
})
class HealthCheckHttpsHealthCheck(object):
class HealthCheckHttpshealthcheck(object):
def __init__(self, request, module):
self.module = module
if request:
@ -759,7 +772,7 @@ class HealthCheckHttpsHealthCheck(object):
})
class HealthCheckTcpHealthCheck(object):
class HealthCheckTcphealthcheck(object):
def __init__(self, request, module):
self.module = module
if request:
@ -786,7 +799,7 @@ class HealthCheckTcpHealthCheck(object):
})
class HealthCheckSslHealthCheck(object):
class HealthCheckSslhealthcheck(object):
def __init__(self, request, module):
self.module = module
if request: