storage icon indicating copy to clipboard operation
storage copied to clipboard

lvm vdo: fatal when create lvm vdo with invalid_size of vdo_logical_size

Open yizhanglinux opened this issue 4 years ago • 4 comments

playbook

- hosts: all
  become: true
  vars:
    storage_safe_mode: false
    mount_location: '/opt/test1'
    volume_group_size: '10g'
    volume_size: '9g'
    logical_size: '20g'
    small_logical_size: '8g'
    invalid_size: 'xyz GiB'

  tasks:
    - include_role:
        name: linux-system-roles.storage
 
    - include_tasks: get_unused_disk.yml
      vars:
        min_size: "{{ volume_group_size }}"
        max_return: 1

    - name: Test for correct handling of invalid parameter when creating LVM VDO volume
      block:
        - name: Try to create LVM VDO with invalid size of vdo_logical_size
          include_role:
            name: linux-system-roles.storage
          vars:
            storage_pools:
              - name: pool1
                disks: "{{ unused_disks }}"
                vdo_compression: true
                vdo_deduplication: true
                vdo_logical_size: "{{ invalid_size }}"
                volumes:
                  - name: volume1
                    size: "{{ volume_size }}"
                    mount_point: "{{ mount_location }}"
       
        - name: Unreachable task
          fail:
            msg: UNREACH
       
      rescue:
        - name: Check that we failed in the role
          assert:
            that:
              - ansible_failed_result.msg != 'UNREACH'
            msg: "Role has not failed when it should have"
       
        - name: Verify the output when createing LVM VDO with invalid size of vdo_logical_size
          assert:
            that: "blivet_output.failed and
                   blivet_output.msg|regex_search('TBD') and
                   not blivet_output.changed"
            msg: "Unexpected behavior when creating LVM VDO with invalied parameter"

ansible executing log

TASK [linux-system-roles.storage : manage the pools and volumes to match the specified state] *******************************************
task path: /root/test/storage/tasks/main-blivet.yml:104
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684 `" && echo ansible-tmp-1611634654.4629757-32380-147643857266684="` echo /root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684 `" ) && sleep 0'
Using module file /root/test/storage/library/blivet.py
<localhost> PUT /root/.ansible/tmp/ansible-local-317547haps_lm/tmp5ac8lg_o TO /root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/AnsiballZ_blivet.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/ /root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/AnsiballZ_blivet.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/AnsiballZ_blivet.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "\n** (process:32392): WARNING **: 23:17:34.927: failed to load module btrfs: libbd_btrfs.so.2: cannot open shared object file: No such file or directory\nTraceback (most recent call last):\n  File \"/usr/lib64/python3.6/site-packages/bytesize/bytesize.py\", line 351, in __init__\n    self._c_size = SizeStruct.new_from_str(spec)\n  File \"/usr/lib64/python3.6/site-packages/bytesize/bytesize.py\", line 103, in new_from_str\n    get_error(err)\n  File \"/usr/lib64/python3.6/site-packages/bytesize/bytesize.py\", line 86, in get_error\n    raise ex\nbytesize.bytesize.InvalidSpecError: Failed to parse size spec: xyz GiB\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/AnsiballZ_blivet.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/AnsiballZ_blivet.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1611634654.4629757-32380-147643857266684/AnsiballZ_blivet.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.blivet', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 1285, in <module>\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 1282, in main\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 1235, in run_module\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 967, in manage_pool\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 873, in manage\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 851, in _manage_volumes\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 432, in manage\n  File \"/tmp/ansible_blivet_payload_8hlxnyib/ansible_blivet_payload.zip/ansible/modules/blivet.py\", line 572, in _create\n  File \"/usr/lib64/python3.6/site-packages/bytesize/bytesize.py\", line 373, in __init__\n    raise ValueError(e)\nValueError: Failed to parse size spec: xyz GiB\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

TASK [Check that we failed in the role] *************************************************************************************************
task path: /root/test/storage/tests/tests_vdo_misc.yml:276
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Verify the output when createing LVM VDO with invalid size of vdo_logical_size] ***************************************************
task path: /root/test/storage/tests/tests_vdo_misc.yml:282
fatal: [localhost]: FAILED! => {
    "assertion": "blivet_output.failed and blivet_output.msg|regex_search('TBD') and not blivet_output.changed",
    "changed": false,
    "evaluated_to": false,
    "msg": "Unexpected behavior when creating LVM VDO with invalied parameter"
}

PLAY RECAP ******************************************************************************************************************************
localhost                  : ok=36   changed=0    unreachable=0    failed=1    skipped=15   rescued=1    ignored=0   

yizhanglinux avatar Jan 26 '21 04:01 yizhanglinux

There seems to be a missing regular expression (TBD part) in the assert condition that causes the test to fail.

Also please note that parameter functionality and names have been changed and have to be modified for test to work as intended. To see how it works now, please take a look at tests_create_lvmvdo_then_remove.yml

japokorn avatar Jun 23 '21 12:06 japokorn

Further testing proved my original assumption. Closing the issue.

japokorn avatar Jun 24 '21 10:06 japokorn

Further testing proved my original assumption. Closing the issue.

The issue still exists after update the parameter, I think this still can be one valid test case and issue, reopen it.

    - name: Test for correct handling of invalid parameter when creating LVM VDO volume
      block: 
        - name: Try to create LVM VDO with invalid size of vdo_pool_size
          include_role:
            name: linux-system-roles.storage
          vars:
            storage_pools:
              - name: pool1
                disks: "{{ unused_disks }}"
                volumes:
                  - name: volume1
                    compression: true
                    deduplication: true
                    vdo_pool_size: 'xyz GiB'
                    size: "{{ volume_size }}"
                    mount_point: "{{ mount_location }}"
             
        - name: Unreachable task
          fail:
            msg: UNREACH
             
      rescue:
        - name: Check that we failed in the role
          assert:
            that:
              - ansible_failed_result.msg != 'UNREACH'
            msg: "Role has not failed when it should have"
             
        - name: Verify the output when createing LVM VDO with invalid size of vdo_pool_size
          assert:
            that: "blivet_output.failed and
                   blivet_output.msg|regex_search('TBD') and
                   not blivet_output.changed"
            msg: "Unexpected behavior when creating LVM VDO with invalied parameter"

yizhanglinux avatar Jul 11 '21 01:07 yizhanglinux

And as you said, it should be one future enhancement(TBD), how about keep this issue to track this feature.

yizhanglinux avatar Jul 11 '21 01:07 yizhanglinux