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

lib/server: allow migration of in-memory block backends #826

Merged
merged 5 commits into from
Dec 18, 2024

Conversation

gjcolombo
Copy link
Contributor

(N.B. Stacked on #816.)

Register in-memory block backends for lifecycle callouts and teach them to export and import their contents.

Truthfully, this may be somewhat overengineered. Today, in-memory storage backends are only used for the cloud-init drive, which Nexus always marks as read-only. Since the guest can never change the drive's contents, and #807 ensures that propolis-server migration targets always inherit their initial in-memory backend contents from their sources, it is technically legal for the backend just to return Migrator::Empty if it's read-only (and return Migrator::NonMigratable if it's writable). However, this makes the Propolis lib assume things about the way propolis-server drives migrations, which seemed like a layering violation, so this change just does what's needed to migrate the backend's current data in all cases.

One downside of this approach is that the serialized backend contents show up in migration logs (as part of the giant blob logged in the destination's device_state function). It may make sense to adjust this logging so that the serialized device payloads are removed from this log message. See #825 for more thoughts on this. I think this change would be large enough that if pursued it should be in its own PR.

Add a PHD test for the new migration behavior. This test works on Debian 11, Ubuntu 22.04, and Windows Server 2022. It's skipped on Alpine guests because (for reasons I don't yet understand) the test's use of iflag=direct on that OS isn't sufficient to get reads to hit the actual in-memory backend.

Finally, tweak a few PHD bits:

  • Add a helper to run Powershell cmdlets in Windows VMs.
  • Change the Ubuntu 22.04 adapter's login sequence so that tests run as root. This can be cleaned up in the future by generating an Ubuntu 22.04 image where the default user is a superuser.

Tests: new PHD variation with Alpine, Debian 11, Ubuntu, and WS2022 guests.

Fixes #301.

Copy link
Collaborator

@pfmooney pfmooney left a comment

Choose a reason for hiding this comment

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

Looks reasonable (with one small nit)

lib/propolis/src/block/in_memory.rs Outdated Show resolved Hide resolved
Copy link
Member

@iximeow iximeow left a comment

Choose a reason for hiding this comment

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

seems good! just a few suggestions, take em or leave em

phd-tests/tests/src/disk.rs Outdated Show resolved Hide resolved
phd-tests/tests/src/disk.rs Outdated Show resolved Hide resolved
Base automatically changed from gjcolombo/spec-key to master December 18, 2024 18:46
This test launches a VM with a disk backed by an in-memory backend,
modifies the disk, migrates the VM, and ensures that the changes are
still present on the migration target.

Tune a few things up along the way:

- Add a missing `with_context` in the artifact store.
- Add an affordance to set the minimum size of a PHD FAT volume
  (previously the size was determined solely by the number of files a
  test added to the volume).
- Tweak the Ubuntu 22.04 guest adapter's startup sequence so that tests
  run as root (so that they don't need to elevate with `sudo` to run
  commands that Just Work on other guest OSes that run as a superuser).
@gjcolombo gjcolombo force-pushed the gjcolombo/migrate-in-memory-backends branch from ef7998c to 488bc6a Compare December 18, 2024 18:48
@gjcolombo gjcolombo merged commit 7d94141 into master Dec 18, 2024
11 checks passed
@gjcolombo gjcolombo deleted the gjcolombo/migrate-in-memory-backends branch December 18, 2024 19:46
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.

In-memory disk backends need better migration support
3 participants