mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Add healthcheck option 'request_interval' for Route53 provider
Route53 allows to specify an interval for its health checks. To maintain backward compatibility, the default for this option when ommited is 10 (fast check).
This commit is contained in:
@@ -106,6 +106,7 @@ test:
|
||||
| Key | Description | Default |
|
||||
|--|--|--|
|
||||
| measure_latency | Show latency in AWS console | true |
|
||||
| request_interval | Healthcheck interval [10\|30] seconds | 10 |
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -118,6 +119,7 @@ test:
|
||||
route53:
|
||||
healthcheck:
|
||||
measure_latency: false
|
||||
request_interval: 30
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -550,14 +550,21 @@ class Route53Provider(BaseProvider):
|
||||
.get('healthcheck', {}) \
|
||||
.get('measure_latency', True)
|
||||
|
||||
def _healthcheck_request_interval(self, record):
|
||||
interval = record._octodns.get('route53', {}) \
|
||||
.get('healthcheck', {}) \
|
||||
.get('request_interval')
|
||||
return interval if (interval in [10, 30]) else 10
|
||||
|
||||
def _health_check_equivilent(self, host, path, protocol, port,
|
||||
measure_latency, health_check,
|
||||
first_value=None):
|
||||
measure_latency, request_interval,
|
||||
health_check, first_value=None):
|
||||
config = health_check['HealthCheckConfig']
|
||||
return host == config['FullyQualifiedDomainName'] and \
|
||||
path == config['ResourcePath'] and protocol == config['Type'] \
|
||||
and port == config['Port'] and \
|
||||
measure_latency == config['MeasureLatency'] and \
|
||||
request_interval == config['RequestInterval'] and \
|
||||
(first_value is None or first_value == config['IPAddress'])
|
||||
|
||||
def get_health_check_id(self, record, ident, geo, create):
|
||||
@@ -576,6 +583,7 @@ class Route53Provider(BaseProvider):
|
||||
healthcheck_protocol = record.healthcheck_protocol
|
||||
healthcheck_port = record.healthcheck_port
|
||||
healthcheck_latency = self._healthcheck_measure_latency(record)
|
||||
healthcheck_interval = self._healthcheck_request_interval(record)
|
||||
|
||||
# we're looking for a healthcheck with the current version & our record
|
||||
# type, we'll ignore anything else
|
||||
@@ -590,6 +598,7 @@ class Route53Provider(BaseProvider):
|
||||
healthcheck_protocol,
|
||||
healthcheck_port,
|
||||
healthcheck_latency,
|
||||
healthcheck_interval,
|
||||
health_check,
|
||||
first_value=first_value):
|
||||
# this is the health check we're looking for
|
||||
@@ -609,7 +618,7 @@ class Route53Provider(BaseProvider):
|
||||
'IPAddress': first_value,
|
||||
'MeasureLatency': healthcheck_latency,
|
||||
'Port': healthcheck_port,
|
||||
'RequestInterval': 10,
|
||||
'RequestInterval': healthcheck_interval,
|
||||
'ResourcePath': healthcheck_path,
|
||||
'Type': healthcheck_protocol,
|
||||
}
|
||||
@@ -624,10 +633,11 @@ class Route53Provider(BaseProvider):
|
||||
self._health_checks[id] = health_check
|
||||
self.log.info('get_health_check_id: created id=%s, host=%s, '
|
||||
'path=%s, protocol=%s, port=%d, measure_latency=%r, '
|
||||
'first_value=%s',
|
||||
'request_interval=%d, first_value=%s',
|
||||
id, healthcheck_host, healthcheck_path,
|
||||
healthcheck_protocol, healthcheck_port,
|
||||
healthcheck_latency, first_value)
|
||||
healthcheck_latency, healthcheck_interval,
|
||||
first_value)
|
||||
return id
|
||||
|
||||
def _gc_health_checks(self, record, new):
|
||||
@@ -741,6 +751,7 @@ class Route53Provider(BaseProvider):
|
||||
healthcheck_protocol = record.healthcheck_protocol
|
||||
healthcheck_port = record.healthcheck_port
|
||||
healthcheck_latency = self._healthcheck_measure_latency(record)
|
||||
healthcheck_interval = self._healthcheck_request_interval(record)
|
||||
fqdn = record.fqdn
|
||||
|
||||
# loop through all the r53 rrsets
|
||||
@@ -763,6 +774,7 @@ class Route53Provider(BaseProvider):
|
||||
healthcheck_protocol,
|
||||
healthcheck_port,
|
||||
healthcheck_latency,
|
||||
healthcheck_interval,
|
||||
health_check):
|
||||
# it has the right health check
|
||||
continue
|
||||
|
||||
@@ -106,6 +106,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
@@ -119,6 +120,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 42,
|
||||
}, {
|
||||
@@ -132,6 +134,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
@@ -145,6 +148,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
@@ -159,6 +163,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}]
|
||||
@@ -710,6 +715,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
@@ -723,6 +729,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}]
|
||||
@@ -746,6 +753,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}]
|
||||
@@ -794,6 +802,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
@@ -807,6 +816,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}]
|
||||
@@ -868,9 +878,9 @@ class TestRoute53Provider(TestCase):
|
||||
self.assertEquals('42', id)
|
||||
stubber.assert_no_pending_responses()
|
||||
|
||||
def test_health_check_measure_latency(self):
|
||||
def test_health_check_provider_options(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
record_true = Record.new(self.expected, 'a', {
|
||||
record = Record.new(self.expected, 'a', {
|
||||
'ttl': 61,
|
||||
'type': 'A',
|
||||
'value': '1.2.3.4',
|
||||
@@ -879,23 +889,28 @@ class TestRoute53Provider(TestCase):
|
||||
},
|
||||
'route53': {
|
||||
'healthcheck': {
|
||||
'measure_latency': True
|
||||
'measure_latency': True,
|
||||
'request_interval': 10,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
measure_latency = provider._healthcheck_measure_latency(record_true)
|
||||
self.assertTrue(measure_latency)
|
||||
latency = provider._healthcheck_measure_latency(record)
|
||||
interval = provider._healthcheck_request_interval(record)
|
||||
self.assertTrue(latency)
|
||||
self.assertEquals(10, interval)
|
||||
|
||||
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.assertTrue(measure_latency)
|
||||
latency = provider._healthcheck_measure_latency(record_default)
|
||||
interval = provider._healthcheck_request_interval(record_default)
|
||||
self.assertTrue(latency)
|
||||
self.assertEquals(10, interval)
|
||||
|
||||
record_false = Record.new(self.expected, 'a', {
|
||||
record = Record.new(self.expected, 'a', {
|
||||
'ttl': 61,
|
||||
'type': 'A',
|
||||
'value': '1.2.3.4',
|
||||
@@ -904,15 +919,18 @@ class TestRoute53Provider(TestCase):
|
||||
},
|
||||
'route53': {
|
||||
'healthcheck': {
|
||||
'measure_latency': False
|
||||
'measure_latency': False,
|
||||
'request_interval': 30,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
measure_latency = provider._healthcheck_measure_latency(record_false)
|
||||
self.assertFalse(measure_latency)
|
||||
latency = provider._healthcheck_measure_latency(record)
|
||||
interval = provider._healthcheck_request_interval(record)
|
||||
self.assertFalse(latency)
|
||||
self.assertEquals(30, interval)
|
||||
|
||||
def test_create_health_checks_measure_latency(self):
|
||||
def test_create_health_checks_provider_options(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
|
||||
health_check_config = {
|
||||
@@ -922,7 +940,7 @@ class TestRoute53Provider(TestCase):
|
||||
'IPAddress': '1.2.3.4',
|
||||
'MeasureLatency': False,
|
||||
'Port': 443,
|
||||
'RequestInterval': 10,
|
||||
'RequestInterval': 30,
|
||||
'ResourcePath': '/_dns',
|
||||
'Type': 'HTTPS'
|
||||
}
|
||||
@@ -959,7 +977,8 @@ class TestRoute53Provider(TestCase):
|
||||
},
|
||||
'route53': {
|
||||
'healthcheck': {
|
||||
'measure_latency': False
|
||||
'measure_latency': False,
|
||||
'request_interval': 30
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -967,7 +986,9 @@ class TestRoute53Provider(TestCase):
|
||||
|
||||
id = provider.get_health_check_id(record, 'AF', record.geo['AF'], True)
|
||||
ml = provider.health_checks[id]['HealthCheckConfig']['MeasureLatency']
|
||||
self.assertEqual(False, ml)
|
||||
ri = provider.health_checks[id]['HealthCheckConfig']['RequestInterval']
|
||||
self.assertFalse(ml)
|
||||
self.assertEquals(30, ri)
|
||||
|
||||
def test_health_check_gc(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
@@ -1059,6 +1080,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
@@ -1072,6 +1094,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
@@ -1085,6 +1108,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}]
|
||||
@@ -1262,6 +1286,7 @@ class TestRoute53Provider(TestCase):
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}],
|
||||
@@ -1365,7 +1390,8 @@ class TestRoute53Provider(TestCase):
|
||||
'ResourcePath': '/_dns',
|
||||
'Type': 'HTTPS',
|
||||
'Port': 443,
|
||||
'MeasureLatency': True
|
||||
'MeasureLatency': True,
|
||||
'RequestInterval': 10,
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}],
|
||||
|
||||
Reference in New Issue
Block a user