ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
841 stars 1.54k forks source link

lvol: Ansible on 2nd and later runs expanding the Logical Volume size by doubling it, rather than locking it at 50% of the VG #290

Closed vburamdo closed 4 years ago

vburamdo commented 4 years ago
SUMMARY

Issue is caused by Ansible on 2nd and later runs expanding the Logical Volume size by doubling it, rather than locking it at 50% of the VG.

ISSUE TYPE
COMPONENT NAME

lvol

ANSIBLE VERSION
ansible 2.9.7
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /root/.local/lib/python2.7/site-packages/ansible
  executable location = /root/bin/ansible
  python version = 2.7.5 (default, Nov 27 2019, 09:57:45) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39.0.1)]
CONFIGURATION
OS / ENVIRONMENT

OS version: OracleLinux 7.x

STEPS TO REPRODUCE
- name: 'Ensure partitions exist'
  parted:
    align: 'optimal'
    device: '{{ item }}'
    label: 'gpt'
    name: 'nvme'
    number: '1'
    part_end: '100%'
    part_start: '0%'
    state: 'present'
  loop:
     - '/dev/nvme0n1'
     - '/dev/nvme1n1'
- name: 'Ensure vg_nvme exists'
  lvg:
    pvs: /dev/nvme0n1p1,/dev/nvme1n1p1
    state: 'present'
    vg: 'vg_nvme'
- name: 'Ensure lv_nvme exists'
  lvol:
    active: 'yes'
    lv: 'lv_nvme'
    opts: '--type raid1'
    resizefs: 'yes'
    shrink: 'yes'
    size: '50%VG'
    state: 'present'
    vg: 'vg_nvme'
- name: 'Ensure filesystem exists'
  filesystem:
    dev: '/dev/mapper/vg_nvme-lv_nvme'
    fstype: 'xfs'
- name: 'Ensure filesystem mounted'
  mount:
    backup: 'yes'
    dump: '1'
    fstype: 'xfs'
    opts: 'defaults'
    passno: '2'
    path: '/nvme'
    src: '/dev/mapper/vg_nvme-lv_nvme'
    state: 'mounted'
EXPECTED RESULTS
ACTUAL RESULTS
first run:
[root@vmdenseio216-test ~]# df -hP /nvme
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_nvme-lv_nvme 3.0T 33M 3.0T 1% /nvme
[root@vmdenseio216-test ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_nvme 2 1 0 wz--n- 11.64t 5.82t
[root@vmdenseio216-test ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_nvme vg_nvme rwi-aor--- 2.91t 0.52
[root@vmdenseio216-test ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/nvme0n1p1 vg_nvme lvm2 a-- 5.82t 2.91t
/dev/nvme1n1p1 vg_nvme lvm2 a-- 5.82t 2.91t
[root@vmdenseio216-test ~]#

Second run:
[root@vmdenseio216-test ~]# df -hT /nvme
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_nvme-lv_nvme xfs 5.9T 33M 5.9T 1% /nvme
[root@vmdenseio216-test ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_nvme 2 1 0 wz--n- 11.64t 0
[root@vmdenseio216-test ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_nvme vg_nvme rwi-aor--- 5.82t 0.51
[root@vmdenseio216-test ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/nvme0n1p1 vg_nvme lvm2 a-- 5.82t 0
/dev/nvme1n1p1 vg_nvme lvm2 a-- 5.82t 0
[root@vmdenseio216-test ~]#
ansibullbot commented 4 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 4 years ago

cc @MorrisA @abulimov @bcoca @d-little @flynn1973 @gforster @jhoekx @kairoaraujo @marvin-sinister @mator @molekuul @ramooncamacho @wtcross click here for bot help

mator commented 4 years ago

didn't looked at the code yet, still a quick comment, that xfs filesystem does not support shrinking...

danielmotaleite commented 4 years ago

Looks like this is the same problem as https://github.com/ansible/ansible/issues/29201 (lvol module is not idempotent)

There was a PR https://github.com/ansible/ansible/pull/69136 that would fix this 3 years old problem... and it was a simple fix

vburamdo commented 4 years ago

Used the new collection modules [community.general.lvg, community.general.lvol ] but still am facing same issue.

RAID: --type raid1

first run: [root@vmdenseio216 ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_nvme 2 1 0 wz--n- 11.64t 5.82t [root@vmdenseio216 ~]#

Second Run: [root@vmdenseio216 ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_nvme 2 1 0 wz--n- 11.64t 0 [root@vmdenseio216 ~]# [root@vmdenseio216 ~]# pvs PV VG Fmt Attr PSize PFree /dev/nvme0n1p1 vg_nvme lvm2 a-- 5.82t 0 /dev/nvme1n1p1 vg_nvme lvm2 a-- 5.82t 0 [root@vmdenseio216 ~]#

Version details: ansible 2.9.7 config file = /srv/os_mgmt/ansible.cfg configured module search path = [u'/root/.ansible/collections/ansible_collections/community/general/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /bin/ansible python version = 2.7.5 (default, Aug 7 2019, 08:19:52) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39.0.1)]

felixfontein commented 4 years ago

The fix is still alive and kicking in this repo: #229 - it needs reviews and testing though.