Bug 1855520

Summary: Improve error handling on partial unlock failure of encrypted pools
Product: Red Hat Enterprise Linux 8 Reporter: Dennis Keefe <dkeefe>
Component: stratis-cliAssignee: John Baublitz <jbaublitz>
Status: CLOSED ERRATA QA Contact: guazhang <guazhang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.3CC: amulhern, dkeefe, guazhang, jbaublitz
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 2.1.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 03:55:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dennis Keefe 2020-07-10 04:11:55 UTC
Related to https://github.com/stratis-storage/stratis-cli/issues/618

setup

1. Create three key descriptions 
    stratis key set --capture-key fire
    stratis key set --capture-key water
    stratis key set --capture-key earth
2. Create three pools
    stratis pool create --key-desc fire p1 /dev/sdb
    stratis pool create --key-desc water p2 /dev/sdc
    stratis pool create --key-desc earth p3 /dev/sdd
3. reboot
4. Set only one key
    stratis key set --capture-key earth
5. Unlock pool
    stratis pool unlock

The result:
stratis-cli will try to unlock the first pool (p1) and will fail because the key
description is not available then exits without attempting to unlock the rest of
the pools. 

The result should be that stratis-cli should handle this better and continue to 
attempt to unlock the list of encrypted pools.

Comment 3 guazhang@redhat.com 2020-08-06 07:57:43 UTC
Hello

stratis --propagate key set --keyfile-path /tmp/new_key_devsdk test_key_devsdk
stratis --propagate pool create devsdk --key-desc test_key_devsdk /dev/sdk
stratis --propagate key set --keyfile-path /tmp/new_key_devsdl test_key_devsdl


INFO: [2020-08-06 03:31:30] Running: 'stratis pool list'...
Name                      Total Physical   Properties
devsdb   5.46 TiB / 53.77 MiB / 5.46 TiB      ~Ca, Cr
devsdk   5.46 TiB / 53.77 MiB / 5.46 TiB      ~Ca, Cr
devsdl   5.46 TiB / 53.77 MiB / 5.46 TiB      ~Ca, Cr

reboot 


stratis --propagate key set --keyfile-path  /tmp/new_key_devsdl test_key_devsdl

stratis --propagate pool unlock

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/stratis_cli/_main.py", line 43, in the_func
    result.func(result)
  File "/usr/lib/python3.6/site-packages/stratis_cli/_parser/_parser.py", line 87, in wrapped_func
    func(*args)
  File "/usr/lib/python3.6/site-packages/stratis_cli/_actions/_top.py", line 845, in unlock_pools
    raise StratisCliAggregateError("unlock", "pool", errors)
stratis_cli._errors.StratisCliAggregateError: The operation 'unlock' on a resource of type pool failed. The following errors occurred:
Partial action "unlock" failed for pool with UUID 88ca429d746d49a88c63cc7e73ba3385: Cryptsetup error: IO error occurred: Invalid argument (os error 22)
Partial action "unlock" failed for pool with UUID 28539b84cd4549e5b4ee488697ad423f: Cryptsetup error: IO error occurred: Invalid argument (os error 22)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/stratis", line 35, in <module>
    main()
  File "/usr/bin/stratis", line 32, in main
    return run()(sys.argv[1:])
  File "/usr/lib/python3.6/site-packages/stratis_cli/_main.py", line 60, in the_func
    raise StratisCliActionError(command_line_args, result) from err
stratis_cli._errors.StratisCliActionError: Action selected by command-line arguments ['--propagate', 'pool', 'unlock'] which were parsed to Namespace(func=<function add_subcommand.<locals>.wrap_func.<locals>.wrapped_func at 0x7f53d74680d0>, propagate=True) failed
devsdl   5.46 TiB / 53.77 MiB / 5.46 TiB      ~Ca, Cr
devsdl      /dev/dm-3          5.46 TiB   Data
[root@storageqe-24 ~]# stratis pool list
Name                      Total Physical   Properties
devsdl   5.46 TiB / 53.77 MiB / 5.46 TiB      ~Ca, Cr
[root@storageqe-24 ~]# stratis key list
Key Description
test_key_devsdl
[root@storageqe-24 ~]# rpm -qa |grep stratis
stratis-cli-2.1.1-6.el8.noarch
stratisd-2.1.0-1.el8.x86_64

cryptsetup-2.3.3-1.el8.x86_64
4.18.0-221.el8.x86_64

please have a look the error ?

Comment 4 John Baublitz 2020-08-06 13:46:02 UTC
Hello, this actually looks like it's doing what it's supposed to be doing. Based on the commands you've provided and the commands provided by Dennis for reproducing the behavior, the pool devsdl should now be unlocked while the other two should still be locked. When only one key is provided for three encrypted pools with different encryption keys, the CLI attempts to unlock each encrypted pool and will print out a message for each pool where the key has not been set in the keyring while successfully unlocking the pool whose key is set in the keyring. The steps Dennis provided would have stopped at the first error in the previous version of stratis-cli, but with the most recent version, it will try to unlock all devices and will report all devices that could not be successfully unlocked while unlocking the ones that can be successfully unlocked. Let me know if you need additional clarification.

Comment 5 guazhang@redhat.com 2020-08-07 01:30:43 UTC
thanks for the explain, so move the bug to verified

Comment 8 errata-xmlrpc 2020-11-04 03:55:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (stratis-cli bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4794