Skip to content

Conversation

@mulkieran
Copy link
Member

@mulkieran mulkieran commented May 25, 2023

No description provided.

@mulkieran mulkieran self-assigned this May 25, 2023
@mulkieran mulkieran marked this pull request as ready for review May 25, 2023 22:20
@mulkieran mulkieran requested review from bgurney-rh and jbaublitz and removed request for jbaublitz May 25, 2023 22:20
@jbaublitz
Copy link
Member

I just wanted to mention that maybe we should also handle the case (although less likely to be triggered) in handle.rs too.

@mulkieran
Copy link
Member Author

There seems to be a bit of a bug in that, the pool is still started and fully running. If stratisd is stopped and restarted, the pool should appear in either stopped or started pools, but appears in neither.

@mulkieran mulkieran force-pushed the error-if-no-unlock-method branch from a37ee64 to 379337c Compare May 26, 2023 19:19
@mulkieran
Copy link
Member Author

There is a deeper question. By corrupting the devices in a specific way, we can engineer a state where the pool is fully set up, but when we restart Stratis the pool is placed in the stopped pools data structure. If we teardown the pool, we make it impossible to restart it. This is a deeper issue, I'll file a separate issue for that.

@mulkieran mulkieran requested a review from jbaublitz May 30, 2023 15:53
@mulkieran
Copy link
Member Author

@jbaublitz Whoops, I forgot the remark here: #3352 (comment) . Taking a look now.

)
.ok()
.map(|info| StoppedPoolInfo {
.unwrap_or({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this does the right thing. Errors are only returned when they're a mixture of encrypted and unencrypted devices. I think this aspect of the code should be handled in engine/shared.rs in the gather methods. Gather takes a function as a parameter so it can likely be modified to calculate whether it's PoolEncryption::KeyDesc(MaybeInconsistent::Yes), etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the two arguments to gather_encryption_info are constructed, the iterator derived from internal.values() returns None in one place, so that the flattened length is less than the unflattened.

I think that what you're saying is that when the information is being gathered, it is possible to determine what is the encryption info on the devices w/ valid encryption info.

So, if all the devices w/ valid LUKS metadata are KeyDescription only, then you would like to see PoolEncryptionInfo::KeyDesc(MaybeInconsistent::Yes) rather than both showing inconsistent?

I think we can do that, but my own position is that in the general case where the LUKS info is actually missing because invalid, that information is not certainly known, so I decided to use the most confused value.

If all the devices had valid LUKS2 metadata, and each had a key description, but some key descriptions were different from others, then I would think that it would be appropriate to return
`PoolEncryptionInfo::KeyDesc(MaybeInconsistent::Yes), but it actually make more sent to me to return Both``` as I do here, in this situation.

.filter_map(|(pool_uuid, map)| {
map.stopped_pool_info().map(|info| (*pool_uuid, info))
})
.map(|(pool_uuid, map)| (*pool_uuid, map.stopped_pool_info()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct. It seems like we may have been only displaying encrypted pools in general for stopped pools, not just in the case of this bug!

If there is encryption info on some devices but not others, just assume
maximum possible inconsistency in the encryption.

Signed-off-by: mulhern <[email protected]>
@mulkieran mulkieran force-pushed the error-if-no-unlock-method branch from e30e767 to 451b196 Compare May 31, 2023 17:03
@mulkieran mulkieran changed the title Return an error if there is no unlock method Address problem of missing pool in StoppedPools property May 31, 2023
@mulkieran
Copy link
Member Author

I don't think that gather_encryption_info should return an error under any circumstances. At present, encryption_info() on one device in a DeviceSet may return None. If other return Some, then the answer is for the PoolEncryptionInfo to be maximally inconsistent, as it is here. But, that can be done in in the gather_encryption_info method. I'll give that a go. How that relates to the related method gather_pool_name is an interesting question. As ever, I'ld like to do this with a set and some rules.

If exactly one element of the set and that is None, then the pool encryption info is None.

If two elements of the set, then something is inconsistent.
None + anything => maximally inconsistent, since there should be some encryption info on that other device and we have no idea what it is.

Then feed the rest to the from method for PoolEncryptionInfo, as before.

@mulkieran mulkieran moved this to In Progress (long term) in 2025March Mar 5, 2025
@mulkieran mulkieran removed this from 2025February Mar 5, 2025
@mulkieran mulkieran removed this from 2025March Mar 31, 2025
@mulkieran mulkieran moved this to In Progress (long term) in 2025April Mar 31, 2025
@mulkieran mulkieran added this to 2025May May 5, 2025
@mulkieran mulkieran removed this from 2025April May 5, 2025
@mulkieran mulkieran moved this to In Progress (long term) in 2025May May 5, 2025
@mulkieran mulkieran removed this from 2025May Jun 9, 2025
@mulkieran mulkieran moved this to In Progress (long term) in 2025June Jun 9, 2025
@mulkieran mulkieran removed this from 2025June Jul 8, 2025
@mulkieran mulkieran moved this to In Progress (long term) in 2025July Jul 8, 2025
@mulkieran mulkieran removed this from 2025July Aug 11, 2025
@mulkieran mulkieran moved this to In Progress (long term) in 2025August Aug 11, 2025
@mulkieran mulkieran removed this from 2025August Sep 2, 2025
@mulkieran mulkieran moved this to In Progress (long term) in 2025September Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants