Skip to content

Commit

Permalink
Merge pull request #1976 from ceph/rbd_pool
Browse files Browse the repository at this point in the history
Only perform actions on the rbd pool after it has been created
  • Loading branch information
leseb authored Oct 4, 2017
2 parents ee8aa8b + f0fd3aa commit 163c87a
Show file tree
Hide file tree
Showing 27 changed files with 104 additions and 112 deletions.
3 changes: 1 addition & 2 deletions roles/ceph-client/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
include: create_users_keys.yml
when:
- user_config
- global_in_ceph_conf_overrides
- ceph_conf_overrides.global.osd_pool_default_pg_num is defined
- ceph_conf_overrides.get('global', {}).get('osd_pool_default_pg_num', False) != False
4 changes: 0 additions & 4 deletions roles/ceph-client/tasks/pre_requisite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@
when:
- cephx
- copy_admin_key

- name: set_fact global_in_ceph_conf_overrides
set_fact:
global_in_ceph_conf_overrides: "{{ 'global' in ceph_conf_overrides }}"
15 changes: 15 additions & 0 deletions roles/ceph-iscsi-gw/tasks/configure_iscsi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
---
- name: check if a rbd pool exists
command: ceph --cluster {{ cluster }} osd pool ls --format json
register: rbd_pool_exists

- name: get default value for osd_pool_default_pg_num
command: ceph --cluster {{ cluster }} daemon mon.{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} config get osd_pool_default_pg_num
register: osd_pool_default_pg_num
when: "'rbd' not in (rbd_pool_exists.stdout | from_json)"
delegate_to: "{{ groups[mon_group_name][0] }}"

- name: create a rbd pool if it doesn't exist
command: ceph --cluster {{ cluster }} osd pool create rbd {{ (osd_pool_default_pg_num.stdout | from_json).osd_pool_default_pg_num }}
when: "'rbd' not in (rbd_pool_exists.stdout | from_json)"
delegate_to: "{{ groups[mon_group_name][0] }}"

- name: igw_gateway (tgt) | configure iscsi target (gateway)
igw_gateway:
mode: "target"
Expand Down
44 changes: 0 additions & 44 deletions roles/ceph-mon/tasks/ceph_keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,55 +78,11 @@
- ceph_release_num.{{ ceph_release }} > ceph_release_num.jewel
with_items: "{{ groups.get(mgr_group_name, []) }}"

- name: include set_osd_pool_default_pg_num.yml
include: set_osd_pool_default_pg_num.yml

- name: crush_rules.yml
include: crush_rules.yml
when:
- crush_rule_config

- name: test if rbd exists
shell: |
ceph --cluster {{ cluster }} osd pool ls | grep -sq rbd
changed_when: false
failed_when: false
register: rbd_pool_exist

- name: include rbd_pool.yml
include: rbd_pool.yml
when: rbd_pool_exist.rc == 0

- name: include rbd_pool_pgs.yml
include: rbd_pool_pgs.yml
when:
- rbd_pool_exist.rc == 0
- global_in_ceph_conf_overrides
- ceph_conf_overrides.global.osd_pool_default_pg_num is defined

- name: include rbd_pool_size.yml
include: rbd_pool_size.yml
when:
- rbd_pool_exist.rc == 0
- global_in_ceph_conf_overrides
- ceph_conf_overrides.global.osd_pool_default_size is defined

- name: create rbd pool on luminous
shell: ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create rbd {{ ceph_conf_overrides.global.osd_pool_default_pg_num }}
changed_when: false
failed_when: false
when:
- ceph_release_num.{{ ceph_release }} >= ceph_release_num.luminous
- global_in_ceph_conf_overrides
- ceph_conf_overrides.global.osd_pool_default_pg_num is defined
- rbd_pool_exist.rc != 0

- name: include openstack_config.yml
include: openstack_config.yml
when:
- openstack_config
- inventory_hostname == groups[mon_group_name] | last

- name: find ceph keys
shell: ls -1 /etc/ceph/*.keyring
changed_when: false
Expand Down
10 changes: 0 additions & 10 deletions roles/ceph-mon/tasks/docker/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@
- "{{ inventory_hostname == groups[mon_group_name] | last }}"
- not containerized_deployment_with_kv

- name: include ceph-mon/tasks/set_osd_pool_default_pg_num.yml
include: "{{ lookup('env', 'ANSIBLE_ROLES_PATH') | default (playbook_dir + '/roles', true) }}/ceph-mon/tasks/set_osd_pool_default_pg_num.yml"

# create openstack pools only when all mons are up.
- name: include ceph-mon/tasks/set_osd_pool_default_pg_num.yml
include: "{{ lookup('env', 'ANSIBLE_ROLES_PATH') | default (playbook_dir + '/roles', true) }}/ceph-mon/tasks/openstack_config.yml"
when:
- openstack_config
- "{{ inventory_hostname == groups[mon_group_name] | last }}"

- block:
- name: create ceph mgr keyring(s) when mon is containerized
command: docker exec ceph-mon-{{ ansible_hostname }} ceph --cluster {{ cluster }} auth get-or-create mgr.{{ hostvars[item]['ansible_hostname'] }} mon 'allow profile mgr' osd 'allow *' mds 'allow *' -o /etc/ceph/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring
Expand Down
17 changes: 17 additions & 0 deletions roles/ceph-mon/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@
include: docker/main.yml
when: containerized_deployment

- name: include set_osd_pool_default_pg_num.yml
include: set_osd_pool_default_pg_num.yml

# Create the pools listed in openstack_pools
- name: include openstack_config.yml
include: openstack_config.yml
when:
- openstack_config
- inventory_hostname == groups[mon_group_name] | last

# CEPH creates the rbd pool during the ceph cluster initialization in
# releases prior to luminous. If the rbd_pool.yml playbook is called too
# early, the rbd pool does not exist yet.
- name: include rbd_pool.yml
include: rbd_pool.yml
when: ceph_release_num.{{ ceph_release }} < ceph_release_num.luminous

- name: include create_mds_filesystems.yml
include: create_mds_filesystems.yml
when:
Expand Down
30 changes: 19 additions & 11 deletions roles/ceph-mon/tasks/rbd_pool.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
---
- name: check rbd pool usage
- name: test if rbd exists
shell: |
ceph --connect-timeout 5 --cluster {{ cluster }} df | awk '/rbd/ {print $3}'
"{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd pool ls | grep -sq rbd"
changed_when: false
failed_when: false
always_run: true
register: rbd_pool_df
run_once: true
check_mode: true
register: rbd_pool_exist

- name: check pg num for rbd pool
shell: |
ceph --connect-timeout 5 --cluster {{ cluster }} osd pool get rbd pg_num | awk '{print $2}'
changed_when: false
failed_when: false
always_run: true
register: rbd_pool_pgs
- name: include rbd_pool_df.yml
include: rbd_pool_df.yml
when: rbd_pool_exist.rc == 0

- name: include rbd_pool_pgs.yml
include: rbd_pool_pgs.yml
when:
- rbd_pool_exist.rc == 0
- ceph_conf_overrides.get('global', {}).get('osd_pool_default_pg_num', False) != False

- name: include rbd_pool_size.yml
include: rbd_pool_size.yml
when:
- rbd_pool_exist.rc == 0
- ceph_conf_overrides.get('global', {}).get('osd_pool_default_pg_num', False) != False
14 changes: 14 additions & 0 deletions roles/ceph-mon/tasks/rbd_pool_df.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: verify that rbd pool exist
fail:
msg: "rbd pool does not exist in rbd_pool_df"
when: rbd_pool_exist.rc == 0

- name: check rbd pool usage
shell: |
"{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} df | awk '/rbd/ {print $3}'"
changed_when: false
failed_when: false
check_mode: true
run_once: true
register: rbd_pool_df
19 changes: 17 additions & 2 deletions roles/ceph-mon/tasks/rbd_pool_pgs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
---
- name: verify that rbd pool exist
fail:
msg: "rbd pool does not exist in rbd_pool_pgs"
when: rbd_pool_exist.rc == 0

- name: check pg num for rbd pool
shell: |
"{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool get rbd pg_num | awk '{print $2}'"
changed_when: false
failed_when: false
check_mode: true
run_once: true
register: rbd_pool_pgs

- name: destroy and recreate rbd pool if osd_pool_default_pg_num is not honoured
shell: |
ceph --connect-timeout 5 --cluster {{ cluster }} osd pool rm rbd rbd --yes-i-really-really-mean-it
ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create rbd {{ ceph_conf_overrides.global.osd_pool_default_pg_num }}
"{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool delete rbd rbd --yes-i-really-really-mean-it"
"{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool create rbd {{ ceph_conf_overrides.global.osd_pool_default_pg_num }}"
changed_when: false
failed_when: false
run_once: true
when:
- rbd_pool_df.stdout == "0"
- rbd_pool_pgs.stdout != "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}"
13 changes: 10 additions & 3 deletions roles/ceph-mon/tasks/rbd_pool_size.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
---
- name: verify that rbd pool exist
fail:
msg: "rbd pool does not exist in rbd_pool_size"
when: rbd_pool_exist.rc == 0

- name: check size for rbd pool
shell: |
ceph --connect-timeout 5 --cluster {{ cluster }} osd pool get rbd size | awk '{print $2}'
"{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool get rbd size | awk '{print $2}'"
changed_when: false
failed_when: false
always_run: true
check_mode: true
run_once: true
register: rbd_pool_size

- name: change rbd pool size if osd_pool_default_size is not honoured
command: ceph --connect-timeout 5 --cluster {{ cluster }} osd pool set rbd size {{ ceph_conf_overrides.global.osd_pool_default_size }}
command: "{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool set rbd size {{ ceph_conf_overrides.global.osd_pool_default_size }}"
changed_when: false
failed_when: false
run_once: true
when:
- rbd_pool_df.stdout == "0"
- rbd_pool_size.stdout != "{{ ceph_conf_overrides.global.osd_pool_default_size }}"
28 changes: 9 additions & 19 deletions roles/ceph-mon/tasks/set_osd_pool_default_pg_num.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,30 @@
# so people that had 'pool_default_pg_num' declared will get
# the same behaviour
#
- name: check if does global key exist in ceph_conf_overrides
set_fact:
global_in_ceph_conf_overrides: "{{ 'global' in ceph_conf_overrides }}"

- name: check if ceph_conf_overrides.global.osd_pool_default_pg_num is set
set_fact:
osd_pool_default_pg_num_in_overrides: "{{ 'osd_pool_default_pg_num' in ceph_conf_overrides.global }}"
when: global_in_ceph_conf_overrides

- name: get default value for osd_pool_default_pg_num
shell: |
{{ docker_exec_cmd }} ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config get osd_pool_default_pg_num | grep -Po '(?<="osd_pool_default_pg_num": ")[^"]*'
{{ docker_exec_cmd }} ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config get osd_pool_default_pg_num
failed_when: false
changed_when: false
run_once: true
register: default_pool_default_pg_num
when: pool_default_pg_num is not defined or not global_in_ceph_conf_overrides
when:
- pool_default_pg_num is not defined
- ceph_conf_overrides.get('global', {}).get('osd_pool_default_pg_num', False) == False

- name: set_fact osd_pool_default_pg_num pool_default_pg_num
- name: set_fact osd_pool_default_pg_num with pool_default_pg_num (backward compatibility)
set_fact:
osd_pool_default_pg_num: "{{ pool_default_pg_num }}"
when: pool_default_pg_num is defined

- name: set_fact osd_pool_default_pg_num default_pool_default_pg_num.stdout
- name: set_fact osd_pool_default_pg_num with default_pool_default_pg_num.stdout
set_fact:
osd_pool_default_pg_num: "{{ default_pool_default_pg_num.stdout }}"
osd_pool_default_pg_num: "{{ (default_pool_default_pg_num.stdout | from_json).osd_pool_default_pg_num }}"
when:
- pool_default_pg_num is not defined
- default_pool_default_pg_num.rc == 0
- (osd_pool_default_pg_num_in_overrides is not defined or not osd_pool_default_pg_num_in_overrides)
- default_pool_default_pg_num.get('rc') == 0

- name: set_fact osd_pool_default_pg_num ceph_conf_overrides.global.osd_pool_default_pg_num
set_fact:
osd_pool_default_pg_num: "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}"
when:
- global_in_ceph_conf_overrides
- ceph_conf_overrides.global.osd_pool_default_pg_num is defined
- ceph_conf_overrides.get('global', {}).get('osd_pool_default_pg_num', False) != False
1 change: 0 additions & 1 deletion tests/functional/centos/7/bluestore/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ user_config: True
openstack_config: True
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
osd:
bluestore block db size = 67108864
Expand Down
1 change: 0 additions & 1 deletion tests/functional/centos/7/bs-crypt-ded-jrn/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
osd:
bluestore block db size = 67108864
Expand Down
1 change: 0 additions & 1 deletion tests/functional/centos/7/bs-crypt-jrn-col/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
osd:
bluestore block db size = 67108864
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
osd:
bluestore block db size = 67108864
Expand Down
1 change: 0 additions & 1 deletion tests/functional/centos/7/bs-jrn-col/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
osd:
bluestore block db size = 67108864
Expand Down
1 change: 0 additions & 1 deletion tests/functional/centos/7/cluster/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ user_config: True
openstack_config: True
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
nfs_ganesha_stable: true
nfs_ganesha_dev: false
Expand Down
1 change: 0 additions & 1 deletion tests/functional/centos/7/crypt-ded-jrn/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
1 change: 0 additions & 1 deletion tests/functional/centos/7/crypt-jrn-col/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
1 change: 0 additions & 1 deletion tests/functional/centos/7/docker/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ rgw_override_bucket_index_max_shards: 16
rgw_bucket_default_quota_max_objects: 1638400
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
user_config: True
keys:
Expand Down
1 change: 0 additions & 1 deletion tests/functional/centos/7/jrn-col-auto-dm/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
1 change: 0 additions & 1 deletion tests/functional/centos/7/jrn-col-auto/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
1 change: 0 additions & 1 deletion tests/functional/centos/7/jrn-col/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
1 change: 0 additions & 1 deletion tests/functional/centos/7/lvm-osds/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
1 change: 0 additions & 1 deletion tests/functional/tests/mds/test_mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def test_mds_is_up(self, node, host):
@pytest.mark.docker
def test_docker_mds_is_up(self, node, host):
hostname = node["vars"]["inventory_hostname"]
hostname = node["groups"]["mons"][0]["inventory_hostname"]
cmd = "sudo docker exec ceph-mds-{hostname} ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format(
hostname=node["vars"]["inventory_hostname"],
cluster=node["cluster_name"]
Expand Down
1 change: 0 additions & 1 deletion tests/functional/ubuntu/16.04/cluster/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ os_tuning_params:
- { name: fs.file-max, value: 26234859 }
ceph_conf_overrides:
global:
osd_pool_default_pg_num: 8
osd_pool_default_size: 1
debian_ceph_packages:
- ceph
Expand Down
Loading

0 comments on commit 163c87a

Please sign in to comment.