Skip to content
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

Remove dependence on GetScsiUvmPath function #1742

Merged
merged 2 commits into from
May 4, 2023

Conversation

kevpar
Copy link
Member

@kevpar kevpar commented Apr 23, 2023

This is commit 3/6 in a chain. Recommended to review in order. If reviewing a later PR in the chain, you can view individual commits to see just what that PR changes.

GetScsiUvmPath encodes the unfortunate assumption that there is a single guest mount path for each SCSI device host path. This may be correct today, but there is no good reason for it to be treated as an invariant (mounting a SCSI device gives you back an object that tells you where it was mounted) and needs to not be true in the future (so we can do things like mounting multiple partitions from a device).

These commits remove the usage of GetScsiUvmPath, and replace it with just getting the guest path directly from the returned SCSIMount object.

Please see individual commit messages for details.

kevpar added 2 commits May 3, 2023 01:57
Currently, when installing drivers on LCOW, we use GetScsiUvmPath to
check if the VHD is already mounted, and if it is, we assume the drivers
have already been installed, so we can skip doing it again. This check
has a few problems:

- It relies on GetScsiUvmPath, which assumes a single mount-point in the
  guest for a given VHD. This assumption is not safe to make in the face
  of future changes, where we could mount a device (or partitions on it)
  multiple times.
- It assumes the disk has stayed attached the whole time after drivers
  were installed. This may be a safe assumption today, but can be
  fragile in the future.
- It does not work in the case of a VHD containing multiple sets of
  drivers, or a VHD being changed/updated to newer content after first
  install. Again, this is safe given the current overall design today,
  but could break in the future.

This change is still mostly a bandaid fix. Probably what is most correct
is to track driver installation in something with state (the GCS) rather
than using a separately invoked binary to do the in-guest install.
However, this change does address the first issue above, removing the
dependency on GetScsiUvmPath. I do this in the following way:

- Change install-drivers to check if the overlay path exists already,
  and exit with a no-op if it does. This encodes the assumption that the
  overlay path will be consistent for a given driver set.
- Change InstallDrivers in the shim to compute a V5 GUID from the VHD
  path, and use that as part of the overlay path given to the guest.
  This ensures there is a unique guest overlay path for each unique host
  driver VHD path.

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
The WCOW-isolated SCSI mount process currently works as follows:
- In resources_wcow.go, go through each mount on the OCI spec, and if it
  is a SCSI mount, add a mount to the UVM for it.
- in hcsdoc_wcow.go, go through each mount on the OCI spec, use
  GetScsiUvmPath to determine the guest path it was mounted to, and add
  an entry to the container doc for it.

This is quite hacky, as it relies on a 1:1 mapping between host VHDs and
mounts in the guest, and also because it requires us to re-query
information we've already been given. The SCSIMount object returned when
we mounted to the guest can already tell us the guest path.

This change resolves this problem by instead determing the set of guest
mounts that should be added to the container doc at the time when the
SCSI mounts are done, and saving it in the creation options. Then, when
we construct the actual container doc, we just grab those mounts and add
them in.

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
@kevpar kevpar merged commit 4c7925c into microsoft:main May 4, 2023
14 of 16 checks passed
anmaxvl pushed a commit that referenced this pull request Oct 20, 2023
This PR updates our ADO fork to commits in hcsshim up to commit hash [7769a64](7769a64). This includes support for partitioned scsi devices and ensuring filesystem format for lcow scsi devices.

Related work items: #1728, #1740, #1741, #1742, #1743, #1744, #1745, #1747, #1748, #1749, #1750, #1752, #1754, #1756, #1757, #1767, #1769, #1771, #1772, #1773, #1779
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.

None yet

4 participants