From af6b8b7c99a24db213ca5c0c2548f6c36beda20b Mon Sep 17 00:00:00 2001 From: palage4a Date: Mon, 17 Jul 2023 17:20:23 +0300 Subject: [PATCH] Add `twophase_validate_config_timeout` variable In some cases, when we're working with highloaded cluster, which can't apply CW-config with default timeouts, we have to increase all twophase-timeouts. Before the patch, there were only three of four `cartridge.twophase` timeouts: - `twophase_netbox_call_timeoyt` -> `netbox_call_timeout`; - `twophase_upload_config_timeoyt` -> `updload_config_timeout`; - `twophase_apply_config_timeout` -> `apply_config_timeout`; So, we didn't have an ability to set the `validate_config_timeout` variable. Closes #425 --- CHANGELOG.md | 1 + defaults/main.yml | 2 ++ doc/steps.md | 2 ++ doc/variables.md | 2 ++ library/cartridge_apply_app_config.py | 1 + library/cartridge_bootstrap_vshard.py | 1 + library/cartridge_configure_app_config.py | 1 + library/cartridge_configure_auth.py | 1 + library/cartridge_configure_failover.py | 1 + library/cartridge_edit_topology.py | 1 + library/cartridge_failover_promote.py | 1 + library/cartridge_validate_config.py | 2 ++ module_utils/helpers.py | 2 +- tasks/set_instance_facts.yml | 1 + tasks/steps/blocks/check_new_topology.yml | 1 + tasks/steps/bootstrap_vshard.yml | 1 + tasks/steps/configure_app_config.yml | 1 + tasks/steps/configure_auth.yml | 1 + tasks/steps/configure_failover.yml | 1 + tasks/steps/edit_topology.yml | 1 + tasks/steps/failover_promote.yml | 1 + tasks/steps/force_leaders.yml | 1 + tasks/steps/upload_app_config.yml | 1 + unit/test_validate_config.py | 1 + 24 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 943cd049..4f8a336c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ README.md to use the newest tag with new release - Add `backup_instance_dirs` step to archive files of stopped instance - Add `cartridge_restore_backup_path_local` to restore instance from local backup +- Add `twophase_validate_config_timeout` variable ### Fixed diff --git a/defaults/main.yml b/defaults/main.yml index 4f149069..aa311ef9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -91,6 +91,7 @@ weight: null twophase_netbox_call_timeout: null twophase_upload_config_timeout: null twophase_apply_config_timeout: null +twophase_validate_config_timeout: null edit_topology_timeout: null # DEPRECATED edit_topology_healthy_timeout: 60 @@ -278,6 +279,7 @@ cartridge_cached_fact_names_by_target: - twophase_netbox_call_timeout - twophase_upload_config_timeout - twophase_apply_config_timeout + - twophase_validate_config_timeout - edit_topology_timeout - edit_topology_healthy_timeout - edit_topology_allow_missed_instances diff --git a/doc/steps.md b/doc/steps.md index c8ffb6eb..00b8e3ae 100644 --- a/doc/steps.md +++ b/doc/steps.md @@ -288,6 +288,8 @@ Input variables from config (for two-phase commit): while two-phase commit (Cartridge 2.5+ is required); - `twophase_apply_config_timeout` - time in seconds to wait config apply while two-phase commit (Cartridge 2.5+ is required); +- `twophase_validate_config_timeout` - time in seconds to wait config validate + while two-phase commit (Cartridge 2.5+ is required); - `edit_topology_healthy_timeout` - time in seconds to wait until a cluster become healthy after editing topology; - [DEPRECATED] `edit_topology_timeout` - the same timeout as `edit_topology_healthy_timeout`. diff --git a/doc/variables.md b/doc/variables.md index 8d7b7c59..5c32aed2 100644 --- a/doc/variables.md +++ b/doc/variables.md @@ -137,6 +137,8 @@ For more details see [scenario documentation](/doc/scenario.md). commit (Cartridge 2.5+ is required); - `twophase_apply_config_timeout` (`number`): time in seconds to wait config apply while two-phase commit (Cartridge 2.5+ is required); +- `twophase_validate_config_timeout` (`number`): time in seconds to wait config validate while two-phase + commit (Cartridge 2.5+ is required); - `edit_topology_healthy_timeout` (`number`, default: `60`): time in seconds to wait until a cluster become healthy after editing topology; - [DEPRECATED] `edit_topology_timeout` (`number`): the same timeout diff --git a/library/cartridge_apply_app_config.py b/library/cartridge_apply_app_config.py index b3d09c14..ce198da8 100644 --- a/library/cartridge_apply_app_config.py +++ b/library/cartridge_apply_app_config.py @@ -21,6 +21,7 @@ 'netbox_call_timeout': {'required': False, 'type': 'int'}, 'upload_config_timeout': {'required': False, 'type': 'int'}, 'apply_config_timeout': {'required': False, 'type': 'int'}, + 'validate_config_timeout': {'required': False, 'type': 'int'}, } LUA_MODE = 'lua' diff --git a/library/cartridge_bootstrap_vshard.py b/library/cartridge_bootstrap_vshard.py index 60d4cdbe..d3496b0f 100644 --- a/library/cartridge_bootstrap_vshard.py +++ b/library/cartridge_bootstrap_vshard.py @@ -7,6 +7,7 @@ 'netbox_call_timeout': {'required': False, 'type': 'int'}, 'upload_config_timeout': {'required': False, 'type': 'int'}, 'apply_config_timeout': {'required': False, 'type': 'int'}, + 'validate_config_timeout': {'required': False, 'type': 'int'}, } diff --git a/library/cartridge_configure_app_config.py b/library/cartridge_configure_app_config.py index 3500556d..eade31ca 100644 --- a/library/cartridge_configure_app_config.py +++ b/library/cartridge_configure_app_config.py @@ -8,6 +8,7 @@ 'netbox_call_timeout': {'required': False, 'type': 'int'}, 'upload_config_timeout': {'required': False, 'type': 'int'}, 'apply_config_timeout': {'required': False, 'type': 'int'}, + 'validate_config_timeout': {'required': False, 'type': 'int'}, } diff --git a/library/cartridge_configure_auth.py b/library/cartridge_configure_auth.py index 3b642dba..88a0611e 100644 --- a/library/cartridge_configure_auth.py +++ b/library/cartridge_configure_auth.py @@ -8,6 +8,7 @@ 'netbox_call_timeout': {'required': False, 'type': 'int'}, 'upload_config_timeout': {'required': False, 'type': 'int'}, 'apply_config_timeout': {'required': False, 'type': 'int'}, + 'validate_config_timeout': {'required': False, 'type': 'int'}, } diff --git a/library/cartridge_configure_failover.py b/library/cartridge_configure_failover.py index 2dadadb5..872a74c1 100644 --- a/library/cartridge_configure_failover.py +++ b/library/cartridge_configure_failover.py @@ -8,6 +8,7 @@ 'netbox_call_timeout': {'required': False, 'type': 'int'}, 'upload_config_timeout': {'required': False, 'type': 'int'}, 'apply_config_timeout': {'required': False, 'type': 'int'}, + 'validate_config_timeout': {'required': False, 'type': 'int'}, } NEW_FAILOVER_API_CARTRIDGE_VERSION = '2.1.0' diff --git a/library/cartridge_edit_topology.py b/library/cartridge_edit_topology.py index 90f8fc79..410a6c2b 100644 --- a/library/cartridge_edit_topology.py +++ b/library/cartridge_edit_topology.py @@ -12,6 +12,7 @@ 'netbox_call_timeout': {'required': False, 'type': 'int'}, 'upload_config_timeout': {'required': False, 'type': 'int'}, 'apply_config_timeout': {'required': False, 'type': 'int'}, + 'validate_config_timeout': {'required': False, 'type': 'int'}, 'allow_missed_instances': {'required': True, 'type': 'bool'}, 'check_mode': {'required': False, 'type': 'bool', 'default': False}, 'ignore_errors_of_checks': {'required': False, 'type': 'dict', 'default': {}}, diff --git a/library/cartridge_failover_promote.py b/library/cartridge_failover_promote.py index 004823e1..5d74eb6a 100644 --- a/library/cartridge_failover_promote.py +++ b/library/cartridge_failover_promote.py @@ -14,6 +14,7 @@ 'netbox_call_timeout': {'required': False, 'type': 'int'}, 'upload_config_timeout': {'required': False, 'type': 'int'}, 'apply_config_timeout': {'required': False, 'type': 'int'}, + 'validate_config_timeout': {'required': False, 'type': 'int'}, } diff --git a/library/cartridge_validate_config.py b/library/cartridge_validate_config.py index fb517069..2e48f427 100644 --- a/library/cartridge_validate_config.py +++ b/library/cartridge_validate_config.py @@ -31,6 +31,7 @@ 'twophase_netbox_call_timeout', 'twophase_upload_config_timeout', 'twophase_apply_config_timeout', + 'twophase_validate_config_timeout', 'edit_topology_timeout', 'edit_topology_healthy_timeout', 'edit_topology_allow_missed_instances', @@ -137,6 +138,7 @@ 'twophase_netbox_call_timeout': int, 'twophase_upload_config_timeout': int, 'twophase_apply_config_timeout': int, + 'twophase_validate_config_timeout': int, 'edit_topology_timeout': int, 'edit_topology_healthy_timeout': int, 'edit_topology_allow_missed_instances': bool, diff --git a/module_utils/helpers.py b/module_utils/helpers.py index 62a12045..bee8d965 100644 --- a/module_utils/helpers.py +++ b/module_utils/helpers.py @@ -9,7 +9,7 @@ from ansible.module_utils.basic import AnsibleModule DEFAULT_RUN_DIR = '/var/run/tarantool' -TWOPHASE_OPTION_NAMES = ['netbox_call_timeout', 'upload_config_timeout', 'apply_config_timeout'] +TWOPHASE_OPTION_NAMES = ['netbox_call_timeout', 'upload_config_timeout', 'validate_config_timeout', 'apply_config_timeout'] # parameters of instance configuration that can be changed dynamically DYNAMIC_BOX_CFG_PARAMS = { diff --git a/tasks/set_instance_facts.yml b/tasks/set_instance_facts.yml index f3ffc21a..2a7fcbdb 100644 --- a/tasks/set_instance_facts.yml +++ b/tasks/set_instance_facts.yml @@ -93,6 +93,7 @@ twophase_netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' twophase_upload_config_timeout: '{{ twophase_upload_config_timeout }}' twophase_apply_config_timeout: '{{ twophase_apply_config_timeout }}' + twophase_validate_config_timeout: '{{ twophase_validate_config_timeout }}' edit_topology_timeout: '{{ edit_topology_timeout }}' edit_topology_healthy_timeout: '{{ edit_topology_healthy_timeout }}' diff --git a/tasks/steps/blocks/check_new_topology.yml b/tasks/steps/blocks/check_new_topology.yml index 80a566b8..180dafd5 100644 --- a/tasks/steps/blocks/check_new_topology.yml +++ b/tasks/steps/blocks/check_new_topology.yml @@ -9,6 +9,7 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' allow_missed_instances: '{{ edit_topology_allow_missed_instances }}' check_mode: true ignore_errors_of_checks: diff --git a/tasks/steps/bootstrap_vshard.yml b/tasks/steps/bootstrap_vshard.yml index e9e3d35e..5e7d5cf5 100644 --- a/tasks/steps/bootstrap_vshard.yml +++ b/tasks/steps/bootstrap_vshard.yml @@ -17,6 +17,7 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' register: bootstrap_vshard until: not bootstrap_vshard.failed retries: '{{ bootstrap_vshard_retries }}' diff --git a/tasks/steps/configure_app_config.yml b/tasks/steps/configure_app_config.yml index e8cc135a..4b2e4a95 100644 --- a/tasks/steps/configure_app_config.yml +++ b/tasks/steps/configure_app_config.yml @@ -15,5 +15,6 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' run_once: true delegate_to: '{{ control_instance.name }}' diff --git a/tasks/steps/configure_auth.yml b/tasks/steps/configure_auth.yml index 85d751aa..ff316f49 100644 --- a/tasks/steps/configure_auth.yml +++ b/tasks/steps/configure_auth.yml @@ -15,5 +15,6 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' run_once: true delegate_to: '{{ control_instance.name }}' diff --git a/tasks/steps/configure_failover.yml b/tasks/steps/configure_failover.yml index 5edbf817..c991db9b 100644 --- a/tasks/steps/configure_failover.yml +++ b/tasks/steps/configure_failover.yml @@ -15,5 +15,6 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' run_once: true delegate_to: '{{ control_instance.name }}' diff --git a/tasks/steps/edit_topology.yml b/tasks/steps/edit_topology.yml index 22db6770..7da517cc 100644 --- a/tasks/steps/edit_topology.yml +++ b/tasks/steps/edit_topology.yml @@ -18,6 +18,7 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' allow_missed_instances: '{{ edit_topology_allow_missed_instances }}' run_once: true delegate_to: '{{ control_instance.name }}' diff --git a/tasks/steps/failover_promote.yml b/tasks/steps/failover_promote.yml index 8b013e54..5d194f29 100644 --- a/tasks/steps/failover_promote.yml +++ b/tasks/steps/failover_promote.yml @@ -16,5 +16,6 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' run_once: true delegate_to: '{{ control_instance.name }}' diff --git a/tasks/steps/force_leaders.yml b/tasks/steps/force_leaders.yml index 027907af..3b55bf36 100644 --- a/tasks/steps/force_leaders.yml +++ b/tasks/steps/force_leaders.yml @@ -19,5 +19,6 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' run_once: true delegate_to: '{{ control_instance.name }}' diff --git a/tasks/steps/upload_app_config.yml b/tasks/steps/upload_app_config.yml index 2bb2e180..705f6d84 100644 --- a/tasks/steps/upload_app_config.yml +++ b/tasks/steps/upload_app_config.yml @@ -37,6 +37,7 @@ netbox_call_timeout: '{{ twophase_netbox_call_timeout }}' upload_config_timeout: '{{ twophase_upload_config_timeout }}' apply_config_timeout: '{{ twophase_apply_config_timeout }}' + validate_config_timeout: '{{ twophase_validate_config_timeout }}' register: apply_app_config_res - name: 'Add uploaded config to "temporary_files" fact' diff --git a/unit/test_validate_config.py b/unit/test_validate_config.py index 2a4598a4..a7f7f17b 100644 --- a/unit/test_validate_config.py +++ b/unit/test_validate_config.py @@ -128,6 +128,7 @@ 'twophase_netbox_call_timeout', 'twophase_upload_config_timeout', 'twophase_apply_config_timeout', + 'twophase_validate_config_timeout', 'edit_topology_timeout', 'edit_topology_healthy_timeout', 'wait_members_alive_retries',