Skip to content

Commit

Permalink
replace_node.yml: Add a 'dead_nodes_to_ignore' variable
Browse files Browse the repository at this point in the history
Scylla has an 'ignore_dead_nodes_for_replace' config which allows the user
to ignore dead nodes during the replace and so far it was not supported
by this playbook.
This patch adds support to this feature by adding a variable 'dead_nodes_to_ignore'.
This variable should contain a list with the broadcast addresses of the nodes
that should be ignored during the replace.
  • Loading branch information
igorribeiroduarte authored and vladzcloudius committed Aug 15, 2024
1 parent b33fb92 commit 2a44e10
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions example-playbooks/replace_node/replace_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,32 @@
delegate_to: "{{ temporary_seed }}"
run_once: true

- name: Set ignore_dead_nodes_for_replace using host ids
block:
- name: Set dead nodes host ids
set_fact:
_dead_nodes_host_ids: "{{ _dead_nodes_host_ids | default([]) + [item.value] }}"
when: item.key in dead_nodes_to_ignore
loop: "{{ _host_ids.json }}"

- name: Set ignore_dead_nodes_for_replace in scylla.yaml
lineinfile:
path: /etc/scylla/scylla.yaml
regexp: '^(#\s*)?ignore_dead_nodes_for_replace:'
line: "ignore_dead_nodes_for_replace: {{ _dead_nodes_host_ids | join(',')}}"
create: yes
when: dead_nodes_to_ignore|length > 0 and _replace_node_first_boot_grep.failed == false

# If the _replace_node_first_boot_grep failed, it means that in this scylla version we are still using
# addresses instead of host ids for replace, so let's set broadcast addresses in ignore_dead_nodes_for_replace
- name: Set ignore_dead_nodes_for_replace using addresses
lineinfile:
path: /etc/scylla/scylla.yaml
regexp: '^(#\s*)?ignore_dead_nodes_for_replace:'
line: "ignore_dead_nodes_for_replace: {{ dead_nodes_to_ignore | join(',')}}"
create: yes
when: dead_nodes_to_ignore|length > 0 and _replace_node_first_boot_grep.failed

- name: Set replace_node_first_boot
block:
- set_fact:
Expand Down Expand Up @@ -265,6 +291,13 @@
state: absent
when: _replace_node_first_boot_grep.failed

- name: Remove the ignore_dead_nodes_for_replace record
lineinfile:
path: /etc/scylla/scylla.yaml
regexp: '^ignore_dead_nodes_for_replace:'
state: absent
when: dead_nodes_to_ignore|length > 0

- name: Restore seeds list
lineinfile:
path: /etc/scylla/scylla.yaml
Expand Down
4 changes: 4 additions & 0 deletions example-playbooks/replace_node/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ alive_nodes_listen_address: "{{ vars['ansible_'~scylla_nic].ipv4.address }}"
alive_nodes_broadcast_address: "{{ vars['ansible_'~scylla_nic].ipv4.address }}"

cql_port: 9042

# A list with the broadcast addresses of the nodes that are dead and should be ignored during the replace
# These nodes shouldn't be part of the inventory
dead_nodes_to_ignore: []

0 comments on commit 2a44e10

Please sign in to comment.