From 9a25a643e2cb544bd9b4993a126a74ecc482ac2d Mon Sep 17 00:00:00 2001 From: Roman Goncharov Date: Thu, 9 Sep 2021 18:04:12 +0300 Subject: [PATCH] Fix MAX_TIMEOUT value for listener In the database, timeout_client_data, timeout_member_connect, timeout_member_data, timeout_tcp_inspect have an integer type with a maximum size of 2147483647. Now MAX_TIMEOUT in API does not exceed this value and is equal to 24 days (2073600000 seconds). Story: 2009193 Task: 43248 Change-Id: I990b6af1ff880b25e54f6c41ae0c966007f3f098 (cherry picked from commit 3a8f056306bba4502639bfc89752d8a48d694e7f) --- octavia/common/constants.py | 4 ++-- .../tests/functional/api/v2/test_listener.py | 24 +++++++++++-------- ...listener-MAX_TIMEOUT-4c4fdf804a96c34b.yaml | 7 ++++++ 3 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 releasenotes/notes/fix-listener-MAX_TIMEOUT-4c4fdf804a96c34b.yaml diff --git a/octavia/common/constants.py b/octavia/common/constants.py index a3ef16934b..59ed131a3d 100644 --- a/octavia/common/constants.py +++ b/octavia/common/constants.py @@ -228,8 +228,8 @@ DEFAULT_MAX_RETRIES_DOWN = 3 MIN_HM_RETRIES = 1 MAX_HM_RETRIES = 10 -# 1 year: y d h m ms -MAX_TIMEOUT = 365 * 24 * 60 * 60 * 1000 +# 24 days: days d h m ms +MAX_TIMEOUT = 24 * 24 * 60 * 60 * 1000 MIN_TIMEOUT = 0 DEFAULT_TIMEOUT_CLIENT_DATA = 50000 diff --git a/octavia/tests/functional/api/v2/test_listener.py b/octavia/tests/functional/api/v2/test_listener.py index c96a362a3e..4232ef9f3c 100644 --- a/octavia/tests/functional/api/v2/test_listener.py +++ b/octavia/tests/functional/api/v2/test_listener.py @@ -682,17 +682,21 @@ class TestListener(base.BaseAPITest): def test_create_with_timeouts_too_high(self): optionals = { 'timeout_client_data': 1, - 'timeout_member_connect': 2, - 'timeout_member_data': 3, - 'timeout_tcp_inspect': constants.MAX_TIMEOUT + 1, + 'timeout_member_connect': 1, + 'timeout_member_data': 1, + 'timeout_tcp_inspect': 1, } - resp = self.test_create(response_status=400, **optionals).json - fault = resp.get('faultstring') - self.assertIn( - 'Invalid input for field/attribute timeout_tcp_inspect', fault) - self.assertIn( - 'Value should be lower or equal to {0}'.format( - constants.MAX_TIMEOUT), fault) + for field in optionals.items(): + optionals.update({field[0]: constants.MAX_TIMEOUT + 1}) + resp = self.test_create(response_status=400, **optionals).json + optionals.update({field[0]: 1}) + fault = resp.get('faultstring') + self.assertIn( + 'Invalid input for field/attribute {0}'.format( + field[0]), fault) + self.assertIn( + 'Value should be lower or equal to {0}'.format( + constants.MAX_TIMEOUT), fault) def test_create_with_timeouts_too_low(self): optionals = { diff --git a/releasenotes/notes/fix-listener-MAX_TIMEOUT-4c4fdf804a96c34b.yaml b/releasenotes/notes/fix-listener-MAX_TIMEOUT-4c4fdf804a96c34b.yaml new file mode 100644 index 0000000000..d0b6fde838 --- /dev/null +++ b/releasenotes/notes/fix-listener-MAX_TIMEOUT-4c4fdf804a96c34b.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed MAX_TIMEOUT for timeout_client_data, timeout_member_connect, + timeout_member_data, timeout_tcp_inspect API listener. The value was + reduced from 365 days to 24 days, which now does not exceed the value of + the data type in DB.