From 3d94734babc867adc0370bf3af95b94e66174748 Mon Sep 17 00:00:00 2001 From: Felipe Mendes Date: Sun, 3 Jul 2022 21:06:01 -0300 Subject: [PATCH 1/2] Node Role - Check early whether Scylla is installed This commit introduces an early check to determine whether Scylla is already installed on the target system. It provides a mechanism to prevent incorrectly (and dangerously) upgrading a system which may be already part of a running cluster. In such scenarios, we now require `upgrade_version: True`, which delegates ALL upgrade logic to its relevant upgrade section in the role. --- ansible-scylla-node/tasks/main.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ansible-scylla-node/tasks/main.yml b/ansible-scylla-node/tasks/main.yml index a082e26e..7b388a0b 100644 --- a/ansible-scylla-node/tasks/main.yml +++ b/ansible-scylla-node/tasks/main.yml @@ -8,6 +8,16 @@ package_facts: manager: auto +- name: Check whether Scylla is already installed + fail: + msg: > + Detected an existing Scylla installation. + Should you want to upgrade, set `upgrade_version' to True. + when: > + not upgrade_version and + ( 'scylla-server' in ansible_facts.packages or + 'scylla-enterprise-server' in ansible_facts.packages ) + # Upgrade - name: Upgrade Scylla include_tasks: upgrade/main.yml From 5d855a121e91b8c1e5caa83b6a68e48f0dc1f75e Mon Sep 17 00:00:00 2001 From: Felipe Mendes Date: Sun, 3 Jul 2022 22:36:06 -0300 Subject: [PATCH 2/2] Introduce skip_upgrade_check option A funny situation arose when we introduced the option to fail early when Scylla is already installed and upgrade_version == False: It may happen that the role failed during its runtime, therefore leaving the target systems in an inconsistent state. When this happens, if the failure happened AFTER the Scylla package was installed, then the user would be left in an chicken-and-egg situation: They can not re-execute the playbook installing the specified version, as the upgrade will abort since we are upgrading to the same release. Similarly, they can not install Scylla again, as it will complain that the package is already installed. We circumvent that situation by introducing the `skip_upgrade_check` option, which is a failsafe mechanism to allow a role failure to proceed on installation even when `upgrade_version` is False. Needless to say, this option is False by default. --- ansible-scylla-node/defaults/main.yml | 6 ++++++ ansible-scylla-node/tasks/main.yml | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ansible-scylla-node/defaults/main.yml b/ansible-scylla-node/defaults/main.yml index 1b35e118..9748aa6c 100644 --- a/ansible-scylla-node/defaults/main.yml +++ b/ansible-scylla-node/defaults/main.yml @@ -5,6 +5,12 @@ # UPGRADE # ============================== +# Skips role upgrade check. Useful if the role failed in the middle of an installation. +# Values: +# [default] false: Fail when Scylla is installed and the upgrade_version == False +# true: When upgrade_version == False, re-run the install process +skip_upgrade_check: false + # Upgrades Scylla version if a previous installation is detected # Values: # [default] false: don't check for upgrades diff --git a/ansible-scylla-node/tasks/main.yml b/ansible-scylla-node/tasks/main.yml index 7b388a0b..b0db9b97 100644 --- a/ansible-scylla-node/tasks/main.yml +++ b/ansible-scylla-node/tasks/main.yml @@ -13,8 +13,9 @@ msg: > Detected an existing Scylla installation. Should you want to upgrade, set `upgrade_version' to True. + If you are recovering from a failed role run, set `skip_upgrade_check' to True. when: > - not upgrade_version and + not upgrade_version and not skip_upgrade_check and ( 'scylla-server' in ansible_facts.packages or 'scylla-enterprise-server' in ansible_facts.packages )