Remove osd from the restored ceph crushmap

When loading the ceph crushmap during platform restore, ceph_mon
crashes. This is due to upstream behavior where it is expected that
if you load a crushmap with OSDs defined they are actually reflected
in the osdmap. If they are not ceph_mon will crash when 'ceph osd tree'
is called by ceph-manager when checking ceph cluster health. The solution
is to remove all the OSDs from the restored crushmap. When OSDs are
created either during host unlock or via runtime manifest, they will be
re-inserted into the crushmap.

Change-Id: I5b98706b1e561f028d72f1f8028a84ce75851ef4
Story: 2004761
Task: 35965
Signed-off-by: Wei Zhou <wei.zhou@windriver.com>
This commit is contained in:
Wei Zhou 2019-07-23 16:41:41 -04:00
parent e79db635d2
commit 64ac595bab
3 changed files with 17 additions and 4 deletions

View File

@ -35,7 +35,7 @@
pxe_config_permdir: "{{ config_permdir }}/pxelinux.cfg"
armada_permdir: "{{ platform_path }}/armada/"
helm_overrides_permdir: "{{ platform_path + '/helm/' + software_version }}"
sysinv_config_permdir: "{{ config_permdir + '/sysinv/' + software_version }}"
sysinv_config_permdir: "{{ platform_path + '/sysinv/' + software_version }}"
# To work around an ansible quirk that regex_replace filter
# is ignored when it is applied to variables in the command module

View File

@ -164,7 +164,7 @@
- name: Set ceph crushmap directory to /opt/platform/sysinv if it is non-AIO system
set_fact:
ceph_crushmap_dir: sysinv_config_permdir
ceph_crushmap_dir: "{{ sysinv_config_permdir }}"
when: system_type != 'All-in-one'
- name: Restore ceph crush map
@ -174,6 +174,17 @@
args:
warn: false
# Need to remove osd info from the crushmap before it is loaded into ceph.
# When osds are created they will be inserted into the crushmap by ceph.
# TODO: There might be a better command to do this, like the rebuild option
# with the ceph-monstore-tool.
- name: Remove osds from the crushmap
shell: >-
crushtool -i {{ ceph_crushmap_dir }}/{{ crushmap_file }} --tree |
awk /osd/'{print $NF}' |
xargs -i crushtool -i {{ ceph_crushmap_dir }}/{{ crushmap_file }} --remove-item {}
-o {{ ceph_crushmap_dir }}/{{ crushmap_file }}
- name: Remove leading '/' from patch-vault directory
set_fact:
short_patch_vault_permdir: "{{ patch_vault_permdir | regex_replace('^\\/', '') }}"

View File

@ -7,7 +7,9 @@ extension_permdir: /opt/extension
patch_vault_permdir: /opt/patch-vault
ldap_permdir: /var/lib/openldap-data
kube_config_dir: "{{ lookup('env', 'KUBECONFIG') }}"
crushmap_file: crushmap.bin.backup
# Default directory where the backup info (e.g. mariadb data, ceph crushmap)
# can be found during restore.
# Default directory where the backup tarball is stored at the end
# of the platform restore. As a continuation of the restore process,
# this backup tarball is needed when restoring the openstack application.
backup_dir: /opt/backups