From 451b196714dd47282f6a453a8e27803dcfa740ea Mon Sep 17 00:00:00 2001 From: mulhern Date: Fri, 26 May 2023 14:53:23 -0400 Subject: [PATCH] Include device set even if encryption info missing If there is encryption info on some devices but not others, just assume maximum possible inconsistency in the encryption. Signed-off-by: mulhern --- .../strat_engine/liminal/device_info.rs | 23 +++++++++++-------- src/engine/strat_engine/liminal/liminal.rs | 8 ++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/engine/strat_engine/liminal/device_info.rs b/src/engine/strat_engine/liminal/device_info.rs index 1b65aa22e2..358f96083e 100644 --- a/src/engine/strat_engine/liminal/device_info.rs +++ b/src/engine/strat_engine/liminal/device_info.rs @@ -669,17 +669,22 @@ impl DeviceSet { /// The encryption information and devices registered for stopped pools to /// be exported over the API. /// - /// Error from gather_encryption_info is converted into an option because - /// unlocked Stratis devices and LUKS2 devices on which the Stratis devices are - /// stored may appear at different times in udev. This is not necessarily - /// an error case and may resolve itself after more devices appear in udev. - pub fn stopped_pool_info(&self) -> Option { - gather_encryption_info( + /// Converts an error result from gather_encryption_info into maximum + /// uncertainty, since the error means that encryption information is + /// completely missing from one device. + pub fn stopped_pool_info(&self) -> StoppedPoolInfo { + let info = gather_encryption_info( self.internal.len(), self.internal.values().map(|info| info.encryption_info()), ) - .ok() - .map(|info| StoppedPoolInfo { + .unwrap_or({ + Some(PoolEncryptionInfo::Both( + MaybeInconsistent::Yes, + MaybeInconsistent::Yes, + )) + }); + + StoppedPoolInfo { info, devices: self .internal @@ -699,7 +704,7 @@ impl DeviceSet { } }) .collect::>(), - }) + } } /// Process the data from a remove udev event. Since remove events are diff --git a/src/engine/strat_engine/liminal/liminal.rs b/src/engine/strat_engine/liminal/liminal.rs index f93a6bdae1..fcdc973a7c 100644 --- a/src/engine/strat_engine/liminal/liminal.rs +++ b/src/engine/strat_engine/liminal/liminal.rs @@ -401,16 +401,12 @@ impl LiminalDevices { stopped: self .stopped_pools .iter() - .filter_map(|(pool_uuid, map)| { - map.stopped_pool_info().map(|info| (*pool_uuid, info)) - }) + .map(|(pool_uuid, map)| (*pool_uuid, map.stopped_pool_info())) .collect(), partially_constructed: self .partially_constructed_pools .iter() - .filter_map(|(pool_uuid, map)| { - map.stopped_pool_info().map(|info| (*pool_uuid, info)) - }) + .map(|(pool_uuid, map)| (*pool_uuid, map.stopped_pool_info())) .collect(), } }