From 7927ec4f119c3a163f487a94698968afabc8c0c2 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:42:27 -0400 Subject: [PATCH] Allow dynamic enabling/disabling of cset Add a separate config to handle enable/disable on the system itself. --- roles/pvc/tasks/ceph/main.yml | 8 ++++++++ .../templates/ceph/ceph-osd-cpuset-enable.j2 | 1 + roles/pvc/templates/ceph/ceph-osd-cpuset.j2 | 20 +++++++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 roles/pvc/templates/ceph/ceph-osd-cpuset-enable.j2 diff --git a/roles/pvc/tasks/ceph/main.yml b/roles/pvc/tasks/ceph/main.yml index 6d17f62..cc5e19e 100644 --- a/roles/pvc/tasks/ceph/main.yml +++ b/roles/pvc/tasks/ceph/main.yml @@ -117,6 +117,14 @@ - ceph-mon@{{ ansible_hostname }} - ceph-mgr@{{ ansible_hostname }} +# This is separate from the block to allow *disabling* of the config without removing it +- name: install ceph-osd-cpuset controller config + template: + src: ceph/ceph-osd-cpuset-enable.j2 + dest: /etc/default/ceph-osd-cpuset + when: + - pvc_shield_osds_enable is defined + # System OSD CPU shielding activation - block: - name: install packages diff --git a/roles/pvc/templates/ceph/ceph-osd-cpuset-enable.j2 b/roles/pvc/templates/ceph/ceph-osd-cpuset-enable.j2 new file mode 100644 index 0000000..018c1ad --- /dev/null +++ b/roles/pvc/templates/ceph/ceph-osd-cpuset-enable.j2 @@ -0,0 +1 @@ +{{ pvc_shield_osds_enable }} diff --git a/roles/pvc/templates/ceph/ceph-osd-cpuset.j2 b/roles/pvc/templates/ceph/ceph-osd-cpuset.j2 index 9c3b4f7..72db818 100755 --- a/roles/pvc/templates/ceph/ceph-osd-cpuset.j2 +++ b/roles/pvc/templates/ceph/ceph-osd-cpuset.j2 @@ -33,20 +33,28 @@ done # Determine our CPU count CPU_COUNT="$( grep '^CPU(s)' <<<"${CPU_INFO}" | awk '{ print $NF }' )" -echo "CPU count: ${CPU_COUNT}" # Loop through all the CPUs in the count; if they are not in OSD_CPUS, add them to the SYS_CPUS array -for i in $( seq 0 $(( ${CPU_COUNT} - 1)) ); do +for i in $( seq 0 $(( ${CPU_COUNT} - 1 )) ); do if [[ ! " ${A_OSD_CPUS[*]} " =~ " ${i} " ]]; then A_SYS_CPUS+=( $i ) fi done -# Convert arrays into CSV -OSD_MEMS="$( IFS=, ; echo "${A_OSD_MEMS[*]}" )" -OSD_CPUS="$( IFS=, ; echo "${A_OSD_CPUS[*]}" )" -SYS_CPUS="$( IFS=, ; echo "${A_SYS_CPUS[*]}" )" +if [[ $( cat /etc/default/ceph-osd-cpuset ) == "True" ]]; then + # Convert arrays into CSV + OSD_MEMS="$( IFS=, ; echo "${A_OSD_MEMS[*]}" )" + OSD_CPUS="$( IFS=, ; echo "${A_OSD_CPUS[*]}" )" + SYS_CPUS="$( IFS=, ; echo "${A_SYS_CPUS[*]}" )" +else + # Configs installed but disabled, so use all CPUs for everything + OSD_MEMS="${SYS_MEMS}" + OSD_CPUS="0-$(( ${CPU_COUNT} - 1 ))" + SYS_CPUS="0-$(( ${CPU_COUNT} - 1 ))" +fi +echo "Enabled: $( cat /etc/default/ceph-osd-cpuset )" +echo "CPU count: ${CPU_COUNT}" echo "OSD CPUs: ${OSD_CPUS}" echo "OSD Mems: ${OSD_MEMS}" echo "System/VM CPUs: ${SYS_CPUS}"