-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧹 Split device discovery from partition discovery in blockdevices.go #4115
Conversation
eaa5cd9
to
c2c7e5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, err | ||
} | ||
var device snapshot.BlockDevice | ||
var deviceErr error | ||
// if we have exactly one device present at the LUN we can directly point the volume mounter towards it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be update? we, on top, look for the block device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it says that we have exactly one device that is found through the LUN lookup, which is what the if
check does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is absolutely a nitpick, my point here was that, we added an extra step here, we are no longer just passing the volume path directly, we now try to find the block.
That's all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, i see your point, ive adjusted it
@@ -57,7 +57,7 @@ func filterScsiDevices(scsiDevices scsiDevices, lun int) []scsiDeviceInfo { | |||
// there can be multiple devices mounted at the same LUN. | |||
// the LUN so we need to find all the blocks, mounted at that LUN. then we find the first one | |||
// that has no mounted partitions and use that as the target device. this is a best-effort approach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we please update this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would you like to have updated? it still is relevant to the code it refers to
sortPartitionsBySize(partitions) | ||
|
||
// return the largest partition. we can extend this to be a parameter in the future | ||
devFsName := "/dev/" + partitions[0].Name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only sort the partitions to return the largest one, if feels a waste of processing.
I know that we won't have a huge number of partitions so, processing here is low-cost, but if feels that the sorting is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can also replace this with iterating over and keeping track of the one with the largest size. this just felt like less code
370b91f
to
4ba969f
Compare
Signed-off-by: Preslav <preslav@mondoo.com>
d59d704
to
e3c7f44
Compare
Split device discovery from partition discovery entirely. This means that the code is now more predictable and makes less assumptions.