redhat-cop / infra.lvm_snapshots

Ansible roles for LVM snapshot management
MIT License
8 stars 7 forks source link

LVM SNAPSHOT CREATE FAILURE WITH LVM THIN POOL (NOT SPECIFYING SIZE) #76

Open grtxghe opened 2 months ago

grtxghe commented 2 months ago

Hi,

When trying to use the collection/role infra.lvm_snapshots.snapshot_create, it fails when there is lvm thin pool in the managed node. Snashot and rollback works fine with regular LVM but not when thin pool is used.

ANSIBLE IN USE: from RH-SAT 6.15 RH-SATELLITE: ANSIBLE JOB TEMPLATE ANSIBLE VERSION: ansible-core-2.16.3-2.el8.x86_64 ANSIBLE COLLECTIONS :

# /etc/ansible/collections/ansible_collections
Collection                  Version
--------------------------- -------
ansible.posix               1.5.4
community.general           9.2.0
infra.lvm_snapshots         2.1.0
TASK [ansible.builtin.debug] ***************************************************
ok: [examplecustomer19.ar.custy] => {
    "msg": [
        "INFO: OPERATING PARAMETERS",
        "---------------------------------",
        "INFO: TGT CONTENT HOST RHEL OS     : '8'",
        "INFO: TGT CONTENT HOST HOSTNAME    : 'examplecustomer19'",
        "INFO: TGT CONTENT HOST FQDN        : 'examplecustomer19.ar.custy'",
        "---------------------------------",
        "INFO: TGT RHSM-ENVIRONMENT         : 'DESA/S-RHEL-8'",
        "INFO: TGT PATCHING COMMAND         : '/usr/bin/dnf install sos'",
        "---------------------------------",
        "INFO: TGT AT TASK UNIT             : 'minutes'",
        "INFO: TGT AT TASK COUNT            : '8'",
        "---------------------------------",
        "INFO: TGT LVM SNAP NAME PREFIX     : 'xcustomer_pse'",
        "INFO: TGT LVM SNAP NAME TIMESTAMP  : '2024090412'",
        "INFO: TGT LVM SNAP SET NAME        : 'xcustomer_pse2024090412'",
        "INFO: TGT LVM SNAP CREATE BOOT BKP : 'True'",
        "---------------------------------",
        "INFO: TGT LVM SNAP CREATE AUTOEXTEND PCENT  : '20'",
        "INFO: TGT LVM SNAP CREATE AUTOEXTEND TSHOLD : '70'",
        "---------------------------------",
        "INFO: TGT LVM VGs/LVs:",
        [
            {
                "lv": "lv_root",
                "vg": "vg00"
            },
            {
                "lv": "lv_var",
                "vg": "vg00"
           },
            {
                "lv": "lv_opt",
                "vg": "vg00"
            }
        ],
        "---------------------------------",
        "INFO: TGT LVM LVs COUNT : '3'"
    ]
}

```=> DEBUG ADDED TO COLLECTIONS:
TASK [infra.lvm_snapshots.snapshot_create : ansible.builtin.debug] *************
ok: [examplecustomer19.ar.custy] => {
    "msg": [
        "-------------------------",
        {
            "changed": false,
            "failed": false,
            "failed_when_result": false,
            "rc": 0,
            "stderr": "Shared connection to 166.47.102.53 closed.\r\n",
            "stderr_lines": [
                "Shared connection to 166.47.102.53 closed."
            ],
            "stdout": "[{\"vg\": \"vg00\", \"lv\": \"lv_root\", \"size\": \"0.0B\"}, {\"vg\": \"vg00\", \"lv\": \"lv_var\", \"size\": \"0.0B\"}, {\"vg\": \"vg00\", \"lv\": \"lv_opt\", \"size\": \"0.0B\"}]\r\n",
            "stdout_lines": [
                "[{\"vg\": \"vg00\", \"lv\": \"lv_root\", \"size\": \"0.0B\"}, {\"vg\": \"vg00\", \"lv\": \"lv_var\", \"size\": \"0.0B\"}, {\"vg\": \"vg00\", \"lv\": \"lv_opt\", \"size\": \"0.0B\"}]"
            ]
        },
        "-------------------------"
    ]
}

=> COLLECTIONS FAILS FOR THINPOOL LVM WITH NO SIZE:

TASK [infra.lvm_snapshots.snapshot_create : Create snapshots] ******************
failed: [examplecustomer19.ar.custy] (item={'vg': 'vg00', 'lv': 'lv_root', 'size': '0.0B'}) => {"ansible_loop_var": "item", "changed": false, "err": "  --size may not be zero.\n  Run `lvcreate --help' for more information.\n", "item": {"lv": "lv_root", "size": "0.0B", "vg": "vg00"}, "msg": "Creating logical volume 'lv_root' failed", "rc": 3}
failed: [examplecustomer19.ar.custy] (item={'vg': 'vg00', 'lv': 'lv_var', 'size': '0.0B'}) => {"ansible_loop_var": "item", "changed": false, "err": "  --size may not be zero.\n  Run `lvcreate --help' for more information.\n", "item": {"lv": "lv_var", "size": "0.0B", "vg": "vg00"}, "msg": "Creating logical volume 'lv_var' failed", "rc": 3}
failed: [examplecustomer19.ar.custy] (item={'vg': 'vg00', 'lv': 'lv_opt', 'size': '0.0B'}) => {"ansible_loop_var": "item", "changed": false, "err": "  --size may not be zero.\n  Run `lvcreate --help' for more information.\n", "item": {"lv": "lv_opt", "size": "0.0B", "vg": "vg00"}, "msg": "Creating logical volume 'lv_opt' failed", "rc": 3}
PLAY RECAP *********************************************************************
examplecustomer19.ar.custy      : ok=46   changed=8    unreachable=0    failed=1    skipped=3    rescued=0    ignored=0
Exit status: 2
StandardError: Job execution failed

ERROR: --size may not be zero.\n Run `lvcreate --help' for more information.\n" From DOCs: https://github.com/redhat-cop/infra.lvm_snapshots/tree/main/roles/snapshot_create#size The size of the logical volume according to the definition of the size parameter of the community.general.lvol module. To create thin provisioned snapshot of a thin provisioned volume, omit the size parameter or set it to 0

grtxghe commented 2 months ago

Additional Information:

grtxghe commented 2 months ago

ORIGINAL:

- name: Create snapshots
  community.general.lvol:
    vg: "{{ item.vg }}"
    lv: "{{ item.lv }}"
    snapshot: "{{ item.lv }}_{{ snapshot_create_set_name }}"
    size: "{{ item.size | default(omit) }}"
  loop: "{{ snapshot_create_volumes }}"

MODIFICATION:

- name: Create snapshots
  community.general.lvol:
    vg: "{{ item.vg }}"
    lv: "{{ item.lv }}"
    snapshot: "{{ item.lv }}_{{ snapshot_create_set_name }}"
  loop: "{{ snapshot_create_volumes }}"
grtxghe commented 2 months ago

If using the modified task 'Create snapshots':

TASK [infra.lvm_snapshots.snapshot_revert : Verify that the snapshot is active] ***
fatal: [lvmtest5.example.com]: FAILED! => {
    "assertion": "snapshot_revert_lv_attr[0] == 's'",
    "changed": false,
    "evaluated_to": false,
    "msg": "Assertion failed"
}

Rollback will fail.