Skip to content

Commit

Permalink
scylla-node: support new machine image and its tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
tarzanek committed Aug 3, 2023
1 parent 28cb1de commit 56b3033
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 38 deletions.
57 changes: 32 additions & 25 deletions ansible-scylla-node/tasks/Debian_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,30 @@
# Requires a 'scylla_version_to_install' fact to be set to a version string we want to install
- name: Install Scylla
block:
- name: Install 'latest' Scylla

- name: Install 'latest' {{ scylla_edition }} Scylla
block:
- block:
- name: Nuke an OSS pin file if exists
- name: Nuke an {{ scylla_edition }} pin file if exists
file:
state: absent
path: /etc/apt/preferences.d/99-scylla
path: "/etc/apt/preferences.d/99-{{ scylla_package_prefix }}"

- name: Install latest OSS Scylla
- name: Install latest {{ scylla_edition }} Scylla
apt:
name: scylla
name: "{{ scylla_package_prefix }}"
state: latest
when: scylla_edition == 'oss'

- block:
- name: Nuke an Enterprise pin file if exists
file:
state: absent
path: /etc/apt/preferences.d/99-scylla-enterprise

- name: Install latest Enterprise Scylla
- name: Install latest {{ scylla_edition }} Scylla machine image
apt:
name: scylla-enterprise
name: "{{ scylla_package_prefix }}-machine-image"
state: latest
when: scylla_edition == 'enterprise'

when: scylla_version_to_install == 'latest'

### Handle non-latest version installation
- name: Install explicitly specified Scylla version
block:
- name: Set Scylla package prefix as OSS
set_fact:
scylla_package_prefix: "scylla"
when: scylla_edition == 'oss'

- name: Set Scylla package prefix as Enterprise
set_fact:
scylla_package_prefix: "scylla-enterprise"
when: scylla_edition == 'enterprise'

- name: Get versions of {{ scylla_edition }} package
# 'apt list -a' output has a package version as a second column and an arch as a third one.
Expand Down Expand Up @@ -75,10 +60,32 @@
group: root
mode: '0644'

- name: "Install {{ aptversions.stdout }}"
- name: "Install {{ aptversions.stdout }} {{ scylla_edition }}"
apt:
name: "{{ scylla_package_prefix }}={{ aptversions.stdout }}"
state: present
allow_downgrade: yes

- name: Get versions of {{ scylla_edition }} machine image package
# 'apt list -a' output has a package version as a second column and an arch as a third one.
# Let's filter by the arch first and then cut the version column.
# Then we will filter out all rows that start with a requested version string followed by a digit to filter out version like 2021.1.11 when 2021.1.1 was requested.
# And finally, we are going to get rid of duplications.
shell: apt list -a {{ scylla_package_prefix }}-machine-image 2>/dev/null | awk '{split($0,a," "); print a[2]}' | egrep "^{{ stripped_scylla_machine_image_version_escaped }}" | sort | uniq
register: aptversions_machine_image
vars:
stripped_scylla_machine_image_version_escaped: "{{ scylla_version_split[0][0] | regex_escape }}\\-"

- name: "Validate scylla-machine image version correctness"
ansible.builtin.fail:
msg: "Too many/few choices for a requested version '{{ stripped_scylla_machine_image_version_escaped }}': {{ aptversions_machine_image.stdout_lines }}. Fix your Scylla scylla_version or scylla_deb_repos/scylla_repo_keys!"
when: aptversions_machine_image.stdout_lines | length != 1

- name: "Install {{ aptversions_machine_image.stdout }} {{ scylla_edition }} machine image"
apt:
name: "{{ scylla_package_prefix }}-machine-image={{ aptversions_machine_image.stdout }}*"
state: present
allow_downgrade: yes

when: scylla_version_to_install != 'latest'
become: true
35 changes: 22 additions & 13 deletions ansible-scylla-node/tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,43 @@
when: item.split(".")[-1] == "repo"
become: true

- name: Install Scylla
- name: Install {{ scylla_edition }}
block:
- name: Install latest OSS Scylla
- name: Install latest {{ scylla_edition }} Scylla
yum:
name: scylla
name: "{{ scylla_package_prefix }}"
state: latest
lock_timeout: 60
when: scylla_version == 'latest' and scylla_edition == 'oss'
when: scylla_version == 'latest'

- name: Install latest Enterprise Scylla
- name: Install latest {{ scylla_edition }} Scylla machine image
yum:
name: scylla-enterprise
name: "{{ scylla_package_prefix }}-machine-image"
state: latest
when: scylla_version == 'latest' and scylla_edition == 'enterprise'
lock_timeout: 60
when: scylla_version == 'latest'

- name: Install specified OSS Scylla
- name: Install specified {{ scylla_edition }} Scylla
yum:
name: "scylla-{{ scylla_version }}"
name: "{{ scylla_package_prefix }}-{{ scylla_version }}"
state: present
lock_timeout: 60
when: scylla_version != 'latest' and scylla_edition == 'oss'
when: scylla_version != 'latest'

- name: Split Scylla version by '-'
set_fact:
scylla_version_split: "{{ scylla_version | regex_findall(regexp, ignorecase=True) }}"
vars:
# All we know that the version is a string comprised of 3 parts separated by '-'
regexp: '^([^\-]+)-([^\-]+)-([^\-]+)$'

- name: Install specified Enterprise Scylla
- name: Install specified {{ scylla_edition }} Scylla machine image
yum:
name: "scylla-enterprise-{{ scylla_version }}"
name: "{{ scylla_package_prefix }}-machine-image-{{ scylla_version_split[0][0] }}"
state: present
lock_timeout: 60
when: scylla_version != 'latest' and scylla_edition == 'enterprise'
when: scylla_version != 'latest'

become: true

- name: Configure SELinux
Expand Down
19 changes: 19 additions & 0 deletions ansible-scylla-node/tasks/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@

- name: Collect IO settings for the first node of every DC
block:
- name: check for existing io_properties for cloud run
stat:
path: /etc/scylla.d/io_properties.yaml
register: io_prop_cloud_stat

- name: check for scylla_cloud_io_setup
stat:
path: /opt/scylladb/scylla-machine-image/scylla_cloud_io_setup
register: io_cloud_setup

- name: Run IO setup in case this is pre-configured environment
shell: |
/opt/scylladb/scylla-machine-image/scylla_cloud_io_setup
become: true
# if above is not found leverage /opt/scylladb/python3/bin/python3 /opt/scylladb/scylla-machine-image/lib/scylla_cloud_io_setup.py ?
# or provide our own role runner for pre 2022.2.1 ?
when: (io_cloud_setup.stat.exists) and (io_prop_cloud_stat.stat.exists|bool == False) and (present_scylla_disks.stdout|int > 0)
# we should maybe add a better way how to detect if this is cloud and run it, otherwise fallback to below (though above should fall back to it too, but it was broken in early 2022.1 and 2022.2.0)

- name: check for existing io_properties
stat:
path: /etc/scylla.d/io_properties.yaml
Expand Down
10 changes: 10 additions & 0 deletions ansible-scylla-node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
package_facts:
manager: auto

- name: Set Scylla package prefix as OSS
set_fact:
scylla_package_prefix: "scylla"
when: scylla_edition == 'oss'

- name: Set Scylla package prefix as Enterprise
set_fact:
scylla_package_prefix: "scylla-enterprise"
when: scylla_edition == 'enterprise'

# Upgrade
- name: Upgrade Scylla
include_tasks: upgrade/main.yml
Expand Down

0 comments on commit 56b3033

Please sign in to comment.