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

feat: Support multiple volumes on virtual machines #2287

Open
wants to merge 54 commits into
base: master
Choose a base branch
from

Conversation

adityahase
Copy link
Member

@adityahase adityahase commented Nov 18, 2024

Currently, we place all the data on a single EBS volume (root partition). This feature supports placing some of the data on another volume.

So that, we can

  1. Move data between machines (right now this is not very easy to do, but possible) without downtime
  2. Change the virtual machine's root volume (base image) without downtime

By default, the "movable" data is placed on a separate volume

  • /var/lib/mysql and /etc/mysql for DB servers
  • /home/frappe/benches for app servers

Instead of directly mounting the filesystem to /var/lib/mysql. We mount it to /opt/volumes/mariadb and then bind mount /opt/volumes/mariadb/var/lib/mysql to /var/lib/mysql. This gets us two things.

  • We don't need a special mounting scheme for the default case (mount /var/lib/mysql from the single volume)
  • We can have two mount points (/etc/mysql and /var/lib/mysql)

To guarantee mount point consistency we use UUID in fstab (instead of device name or volume IDs). Data volumes are unpartitioned and ext4 formatted.

This feature is built to make moving from Intel -> ARM easy.

These are argument for the `mount` command (and /etc/fstab)
/var/lib/mysql and /etc/mysql for Database Server
/home/frappe/benches for Server
…used

If MariaDB gets activated, then mounts will be activated as well.
If one of the mounts fails to activate, MariaDB will not be started.
If one of the mounts is explicitly stopped (or restarted), MariaDB will be stopped (or restarted).

If one of the mounts are stopped, MariaDB will be stopped too.

The mounts strictly have to be in active state for MariaDB to also be in active state.
Reference: https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#BindsTo=
Converts None to "" instead of "None"
EBS Volume ID will change when we start a new machine from an image. Since the ID is only known after the machine boots. We have to wait for the machine to boot and then run a playbook to reconfigure the mount.

But UUID remains the same. so, we don't need to change anything in the new machine at the first boot.

Reference: https://aws.amazon.com/blogs/compute/how-to-mount-linux-volume-and-keep-mount-point-consistency/
/home/frappe/benches directory needs to be owned by frappe

There are other ways of doing this. But this seems useful.
mysql user isn't created when volumes are mounted
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 21.13208% with 209 lines in your changes missing coverage. Please review.

Project coverage is 39.41%. Comparing base (61ae711) to head (edde8b5).
Report is 38 commits behind head on master.

Files with missing lines Patch % Lines
...ual_machine_migration/virtual_machine_migration.py 0.00% 102 Missing ⚠️
press/press/doctype/server/server.py 23.25% 66 Missing ⚠️
...s/press/doctype/database_server/database_server.py 41.37% 17 Missing ⚠️
...s/press/doctype/virtual_machine/virtual_machine.py 27.77% 13 Missing ⚠️
press/runner.py 45.45% 6 Missing ⚠️
...migration_mount/virtual_machine_migration_mount.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2287      +/-   ##
==========================================
- Coverage   39.80%   39.41%   -0.39%     
==========================================
  Files         373      377       +4     
  Lines       28380    28765     +385     
==========================================
+ Hits        11296    11339      +43     
- Misses      17084    17426     +342     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

VirtualMachineImage.platform should match ServerPlan.platform
arm64 plans should pick arm64 base images
x86_64 plans should pick x86_64 base images
We need to do a few things.

- Find the UUID of the root partition.
- Update fstab to use to old root partition as data partition. Update UUID.
- Drop UEFI and cloudimg-rootfs labels. So the new VM doesn't mount these partitions.
- Drop the extra partitions after migration is complete.
We'll need this to determine which partitions need relabelling
We'll need this to determine which partitions need relabelling
Do best effort match based on the previous plan
This prevents these partitions from being mounted in the machine
Also update fstab we can boot the old machine in case the migration fails
The new machine image still refers to the UUID of the blank data volume.
Remount and update fstab.
Cloud-init (updates host keys and) restarts SSH on first boot.
Sometimes this makes the machine unreachable.
Use x86_64 plans as the default option while creating new servers
TODO: Make this a configuration
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.

1 participant