Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks to ensure poolmetadatasize is not less than 0.5% of poolsize #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions roles/backend_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
tags:
- thickvol

# Run pre-requisites check before creating thinpools
- name: Run pre-requisites tests to create thinpools
import_tasks: thin_pool_prereqs.yml
when: gluster_infra_thinpools is defined
tags:
- thinprereq

# Create a thinpool for the given volume group
- name: Create thin pool
import_tasks: thin_pool_create.yml
Expand Down
2 changes: 1 addition & 1 deletion roles/backend_setup/tasks/thin_pool_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
thinpool: "{{ item.thinpoolname }}"
size: "{{ item.thinpoolsize | default('100%FREE') }}"
opts: " --chunksize {{ lv_chunksize }}
--poolmetadatasize {{ item.poolmetadatasize }}
--poolmetadatasize {{ item.poolmetadatasize | default('16G') }}
--zero n"
with_items: "{{ gluster_infra_thinpools }}"
when: gluster_infra_thinpools is defined
45 changes: 45 additions & 0 deletions roles/backend_setup/tasks/thin_pool_prereqs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# POOLMETADATASIZE:
# The maximum possible size for a metadata LV is *16 GiB*. Gluster *recommends*
# creating the metadata device of the maximum supported size. You can allocate
# less than the maximum if space is a concern, but in this case you should
# allocate a minimum of 0.5% of the pool size.

# Gather the volume group size for the thinpools
- name: Check the volume-group size of the remote host
setup:
filter: 'ansible_lvm'

# Build a new list with the vgsize for the given thinpools. There could be
# cases where thinpoolsize might not be provided. In such cases we compare
# against the vg size
- set_fact:
g_thinpools: "{{ g_thinpools|default([]) + [item|combine({'vgsize':
ansible_facts['lvm']['vgs'][item.vgname]
['size_g']|int})] }}"
loop: "{{ gluster_infra_thinpools }}"
loop_control:
label: "{{item.vgname}}"

# If user provides the POOLMETADATASIZE then validate if it is greater than 0.5%
# of the thinpool size. If the user does not provide POOLMETADATASIZE we default
# to 16G
- name: Fail if the given poolmetadatasize is < 0.05% of poolsize
set_fact:
is_lesser: "{{ item.poolmetadatasize[:-1]|float < 0.005 *
item.thinpoolsize[:-1]|float }}"
with_items: "{{ g_thinpools }}"
when: item.poolmetadatasize is defined and
item.thinpoolsize is defined
failed_when: is_lesser

# If thinpoolsize is not defined, we use the entire vg. Thus, we compare if
# poolmetadatasize is less than 0.5% vg size
- name: Fail if the given poolmetadatasize is < 0.05% of vg size
set_fact:
is_lesser: "{{ item.poolmetadatasize[:-1]|float < 0.005 *
item.vgsize|float }}"
with_items: "{{ g_thinpools }}"
when: item.poolmetadatasize is defined and
item.thinpoolsize is not defined
failed_when: is_lesser