cinder/cinder/tests/unit
Gorka Eguileor 0b2c0d9238 LVM: Fix delete volume error due to lvs failure
Sometimes we get an unexpected failure on the lvs command where it exits
with code 139, which is not one of the 5 predefined ones in the code
ECMD_PROCESSED, ENO_SUCH_CMD, EINVALID_CMD_LINE, EINIT_FAILED, or
ECMD_FAILED.

We've seen this happen mostly on CI jobs when deleting a volume, on the
check to see if the volume is present (``_volume_not_present``) and
makes the whole operation unexpectedly fail.

When looking at the logs we can find other instances of this same exit
code happening in other calls, but those are fortunately to be covered
by retries for other unexpected errors such as bug #1335905 that seem to
make the call eventually succeed.

The stderr of the failure is polluted with debug and warning messages
such as:

  [1] /dev/sda1: stat failed: No such file or directory

      This has been removed [2] from the LVM code indicating it's
      somewhat troublesome, but doesn't explain how.

  [3] Path /dev/sda1 no longer valid for device(8,1)

  [4] WARNING: Scan ignoring device 8:0 with no paths.

But the real error is most likely:

  [5]: Device open /dev/sda 8:0 failed errno 2

On failure we see that error twice, because the code retries it in LVM
trying to workaround some kind of unknown udev race [6].

Since the LVM code indicates that a retry can help, we'll retry on error
139 when calling ``get_lv_info``.

To narrow down the retry we'll only do it on error 139, so we modify the
existing ``retry`` decorator to accept the ``retry`` parameter (same as
the tenacity library) and create our own retry if the
ProcessExecutionError fails with a specific error.

This pattern seems better than blindly retrying all
ProcessExecutionError cases.

[1]: 17f5572bc9/lib/filters/filter-persistent.c (L132)
[2]: 22c5467add
[3]: b84a9927b7/lib/device/dev-cache.c (L1396-L1402)
[4]: b84a9927b7/lib/label/label.c (L798)
[5]: b84a9927b7/lib/label/label.c (L550)
[6]: b84a9927b7/lib/label/label.c (L562-L567)

Closes-Bug: #1901783
Change-Id: I6824ba4fbcb6fd8f57f8ff86ad7132446ac6c504
2021-03-29 16:43:10 +02:00
..
api Dropping explicit unicode literal 2021-03-16 07:31:40 +00:00
attachments Add support volume local cache 2020-09-09 03:42:50 +00:00
backup Add support for RBD fast-diff feature for backups stored in Ceph 2021-03-15 13:48:28 +00:00
brick LVM: Fix delete volume error due to lvs failure 2021-03-29 16:43:10 +02:00
cmd Remove NestedQuotaDriver 2021-01-19 17:43:29 +00:00
compute Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
consistencygroup
db Default type overrides 2020-09-16 14:05:31 +00:00
group Use resource_backend for volumes and groups 2020-08-14 08:13:42 +00:00
image Support mTLS when calling the glance API 2021-03-22 22:00:44 +00:00
keymgr Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
message Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
monkey_patch_example
objects Fix cross-project incremental backups 2020-05-21 09:38:25 -03:00
policies Import HTTPStatus instead of http_client (policy tests) 2020-10-13 10:00:20 -04:00
scheduler Remove six of dir cinder/tests/unit/policies&scheduler&targets/* 2020-10-08 10:58:09 +08:00
targets Remove six of dir cinder/tests/unit/policies&scheduler&targets/* 2020-10-08 10:58:09 +08:00
volume Merge "[PURE] support IPv6 / add parameter pure_iscsi_cidr_list" 2021-03-26 16:35:01 +00:00
windows smbfs: set VHD UUID using volume UUID 2021-02-18 09:54:58 +02:00
zonemanager Update to hacking 4.0.0 2021-02-16 10:54:51 -05:00
__init__.py
cast_as_call.py Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
conf_fixture.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
fake_cluster.py
fake_constants.py Default type overrides 2020-09-16 14:05:31 +00:00
fake_group.py
fake_group_snapshot.py
fake_notifier.py Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
fake_objects.py
fake_service.py Fix migration 112 to use live_data_migration API 2017-10-20 18:24:33 -06:00
fake_snapshot.py Add context to cloning snapshots in remotefs driver 2019-07-10 10:41:15 +02:00
fake_utils.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
fake_volume.py Fix VolumeAttachment is not bound to a Session 2019-03-15 11:29:25 +01:00
policy.yaml [goal] Deprecate the JSON formatted policy file 2020-12-11 18:31:04 -06:00
test.py [goal] Deprecate the JSON formatted policy file 2020-12-11 18:31:04 -06:00
test_api.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_api_urlmap.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_cleanable_manager.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_cmd.py Update to hacking 4.0.0 2021-02-16 10:54:51 -05:00
test_context.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_coordination.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_db_api.py Fix automatic quota sync for temporary volumes 2021-03-26 12:26:15 +01:00
test_db_worker_api.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_evaluator.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_exception.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_fixtures.py Explicitly set expected log level for tests 2017-11-17 16:58:40 -06:00
test_hacking.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_image_utils.py Support format info in fs type drivers 2021-03-12 12:41:12 -05:00
test_interface.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_manager.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_paginate_query.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_policy.py Make sure we pass context objects directly to policy enforcement 2021-02-17 17:44:40 +00:00
test_qos_specs.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00
test_quota.py Remove NestedQuotaDriver 2021-01-19 17:43:29 +00:00
test_quota_utils.py Remove NestedQuotaDriver 2021-01-19 17:43:29 +00:00
test_rpc.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_service.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_service_auth.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_setup_profiler.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_ssh_utils.py Refactor some unit tests 2020-10-14 11:01:02 +00:00
test_test.py Handle oslo.messaging ping endpoint 2020-09-03 17:04:17 -05:00
test_test_utils.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_utils.py LVM: Fix delete volume error due to lvs failure 2021-03-29 16:43:10 +02:00
test_volume_cleanup.py Introduce flake8-import-order extension 2020-01-06 09:59:35 -06:00
test_volume_configuration.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_glance_metadata.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_throttling.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_transfer.py Fix: show volume transfer by name for non-admins 2020-08-03 12:46:31 +00:00
test_volume_types.py Modify default/delete volume type logic 2020-08-19 02:07:15 +00:00
test_volume_types_extra_specs.py Move unit test code under tests/unit/ 2020-04-30 18:13:54 -04:00
test_volume_utils.py Move trace methods from utils to volume_utils 2021-02-12 20:16:55 +00:00
utils.py Remove six of files under cinder/test/unit 2020-10-14 09:19:08 +08:00