mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Move measure_latency option to Route53 provider
This commit is contained in:
@@ -89,7 +89,6 @@ test:
|
||||
octodns:
|
||||
healthcheck:
|
||||
host: my-host-name
|
||||
measure_latency: 0
|
||||
path: /dns-health-check
|
||||
port: 443
|
||||
protocol: HTTPS
|
||||
@@ -101,7 +100,26 @@ test:
|
||||
| path | path to check | _dns |
|
||||
| port | port to check | 443 |
|
||||
| protocol | HTTP/HTTPS | HTTPS |
|
||||
| measure_latency | Route53 only: Show latency in AWS console | true |
|
||||
|
||||
#### Route53 Healtch Check Options
|
||||
|
||||
| Key | Description | Default |
|
||||
|--|--|--|
|
||||
| measure_latency | Show latency in AWS console | true |
|
||||
|
||||
```yaml
|
||||
---
|
||||
octodns:
|
||||
healthcheck:
|
||||
host: my-host-name
|
||||
path: /dns-health-check
|
||||
port: 443
|
||||
protocol: HTTPS
|
||||
route53:
|
||||
healthcheck:
|
||||
measure_latency: false
|
||||
```
|
||||
|
||||
|
||||
## Config (`YamlProvider`)
|
||||
|
||||
|
||||
@@ -545,6 +545,13 @@ class Route53Provider(BaseProvider):
|
||||
# We've got a cached version use it
|
||||
return self._health_checks
|
||||
|
||||
def _healthcheck_measure_latency(self, record):
|
||||
return (
|
||||
record._octodns.get('route53', {})
|
||||
.get('healthcheck', {})
|
||||
.get('measure_latency', True)
|
||||
)
|
||||
|
||||
def _health_check_equivilent(self, host, path, protocol, port,
|
||||
measure_latency, health_check,
|
||||
first_value=None):
|
||||
@@ -570,7 +577,7 @@ class Route53Provider(BaseProvider):
|
||||
healthcheck_path = record.healthcheck_path
|
||||
healthcheck_protocol = record.healthcheck_protocol
|
||||
healthcheck_port = record.healthcheck_port
|
||||
healthcheck_measure_latency = record.healthcheck_measure_latency
|
||||
healthcheck_latency = self._healthcheck_measure_latency(record)
|
||||
|
||||
# we're looking for a healthcheck with the current version & our record
|
||||
# type, we'll ignore anything else
|
||||
@@ -584,7 +591,7 @@ class Route53Provider(BaseProvider):
|
||||
healthcheck_path,
|
||||
healthcheck_protocol,
|
||||
healthcheck_port,
|
||||
healthcheck_measure_latency,
|
||||
healthcheck_latency,
|
||||
health_check,
|
||||
first_value=first_value):
|
||||
# this is the health check we're looking for
|
||||
@@ -602,7 +609,7 @@ class Route53Provider(BaseProvider):
|
||||
'FailureThreshold': 6,
|
||||
'FullyQualifiedDomainName': healthcheck_host,
|
||||
'IPAddress': first_value,
|
||||
'MeasureLatency': healthcheck_measure_latency,
|
||||
'MeasureLatency': healthcheck_latency,
|
||||
'Port': healthcheck_port,
|
||||
'RequestInterval': 10,
|
||||
'ResourcePath': healthcheck_path,
|
||||
@@ -622,7 +629,7 @@ class Route53Provider(BaseProvider):
|
||||
'first_value=%s',
|
||||
id, healthcheck_host, healthcheck_path,
|
||||
healthcheck_protocol, healthcheck_port,
|
||||
healthcheck_measure_latency, first_value)
|
||||
healthcheck_latency, first_value)
|
||||
return id
|
||||
|
||||
def _gc_health_checks(self, record, new):
|
||||
@@ -735,7 +742,7 @@ class Route53Provider(BaseProvider):
|
||||
healthcheck_path = record.healthcheck_path
|
||||
healthcheck_protocol = record.healthcheck_protocol
|
||||
healthcheck_port = record.healthcheck_port
|
||||
healthcheck_latency = record.healthcheck_measure_latency
|
||||
healthcheck_latency = self._healthcheck_measure_latency(record)
|
||||
fqdn = record.fqdn
|
||||
|
||||
# loop through all the r53 rrsets
|
||||
|
||||
@@ -189,13 +189,6 @@ class Record(object):
|
||||
except KeyError:
|
||||
return 443
|
||||
|
||||
@property
|
||||
def healthcheck_measure_latency(self):
|
||||
try:
|
||||
return bool(self._octodns['healthcheck']['measure_latency'])
|
||||
except KeyError:
|
||||
return True
|
||||
|
||||
def changes(self, other, target):
|
||||
# We're assuming we have the same name and type if we're being compared
|
||||
if self.ttl != other.ttl:
|
||||
|
||||
@@ -868,6 +868,107 @@ class TestRoute53Provider(TestCase):
|
||||
self.assertEquals('42', id)
|
||||
stubber.assert_no_pending_responses()
|
||||
|
||||
def test_health_check_measure_latency(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
record_true = Record.new(self.expected, 'a', {
|
||||
'ttl': 61,
|
||||
'type': 'A',
|
||||
'value': '1.2.3.4',
|
||||
'octodns': {
|
||||
'healthcheck': {
|
||||
},
|
||||
'route53': {
|
||||
'healthcheck': {
|
||||
'measure_latency': True
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
measure_latency = provider._healthcheck_measure_latency(record_true)
|
||||
self.assertEquals(True, measure_latency)
|
||||
|
||||
record_default = Record.new(self.expected, 'a', {
|
||||
'ttl': 61,
|
||||
'type': 'A',
|
||||
'value': '1.2.3.4',
|
||||
})
|
||||
measure_latency = provider._healthcheck_measure_latency(record_default)
|
||||
self.assertEquals(True, measure_latency)
|
||||
|
||||
record_false = Record.new(self.expected, 'a', {
|
||||
'ttl': 61,
|
||||
'type': 'A',
|
||||
'value': '1.2.3.4',
|
||||
'octodns': {
|
||||
'healthcheck': {
|
||||
},
|
||||
'route53': {
|
||||
'healthcheck': {
|
||||
'measure_latency': False
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
measure_latency = provider._healthcheck_measure_latency(record_false)
|
||||
self.assertEquals(False, measure_latency)
|
||||
|
||||
def test_create_health_checks_measure_latency(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
|
||||
health_check_config = {
|
||||
'EnableSNI': True,
|
||||
'FailureThreshold': 6,
|
||||
'FullyQualifiedDomainName': 'a.unit.tests',
|
||||
'IPAddress': '1.2.3.4',
|
||||
'MeasureLatency': False,
|
||||
'Port': 443,
|
||||
'RequestInterval': 10,
|
||||
'ResourcePath': '/_dns',
|
||||
'Type': 'HTTPS'
|
||||
}
|
||||
|
||||
stubber.add_response('list_health_checks', {
|
||||
'HealthChecks': [],
|
||||
'IsTruncated': False,
|
||||
'MaxItems': '100',
|
||||
'Marker': '',
|
||||
})
|
||||
|
||||
stubber.add_response('create_health_check', {
|
||||
'HealthCheck': {
|
||||
'Id': '42',
|
||||
'CallerReference': self.caller_ref,
|
||||
'HealthCheckConfig': health_check_config,
|
||||
'HealthCheckVersion': 1,
|
||||
},
|
||||
'Location': 'http://url',
|
||||
}, {
|
||||
'CallerReference': ANY,
|
||||
'HealthCheckConfig': health_check_config,
|
||||
})
|
||||
|
||||
record = Record.new(self.expected, 'a', {
|
||||
'ttl': 61,
|
||||
'type': 'A',
|
||||
'value': '2.2.3.4',
|
||||
'geo': {
|
||||
'AF': ['1.2.3.4'],
|
||||
},
|
||||
'octodns': {
|
||||
'healthcheck': {
|
||||
},
|
||||
'route53': {
|
||||
'healthcheck': {
|
||||
'measure_latency': False
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
id = provider.get_health_check_id(record, 'AF', record.geo['AF'], True)
|
||||
ml = provider.health_checks[id]['HealthCheckConfig']['MeasureLatency']
|
||||
self.assertEqual(False, ml)
|
||||
|
||||
def test_health_check_gc(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
|
||||
|
||||
@@ -757,7 +757,6 @@ class TestRecord(TestCase):
|
||||
'host': 'bleep.bloop',
|
||||
'protocol': 'HTTP',
|
||||
'port': 8080,
|
||||
'measure_latency': False
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -765,7 +764,6 @@ class TestRecord(TestCase):
|
||||
self.assertEquals('bleep.bloop', new.healthcheck_host)
|
||||
self.assertEquals('HTTP', new.healthcheck_protocol)
|
||||
self.assertEquals(8080, new.healthcheck_port)
|
||||
self.assertEquals(False, new.healthcheck_measure_latency)
|
||||
|
||||
new = Record.new(self.zone, 'a', {
|
||||
'ttl': 44,
|
||||
@@ -776,7 +774,6 @@ class TestRecord(TestCase):
|
||||
self.assertEquals('a.unit.tests', new.healthcheck_host)
|
||||
self.assertEquals('HTTPS', new.healthcheck_protocol)
|
||||
self.assertEquals(443, new.healthcheck_port)
|
||||
self.assertEquals(True, new.healthcheck_measure_latency)
|
||||
|
||||
def test_inored(self):
|
||||
new = Record.new(self.zone, 'txt', {
|
||||
|
||||
Reference in New Issue
Block a user