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 36 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 30.49645% with 98 lines in your changes missing coverage. Please review.

Project coverage is 39.87%. Comparing base (7a9dede) to head (c5f1776).

Files with missing lines Patch % Lines
press/press/doctype/server/server.py 20.48% 66 Missing ⚠️
...s/press/doctype/database_server/database_server.py 41.37% 17 Missing ⚠️
...s/press/doctype/virtual_machine/virtual_machine.py 30.76% 9 Missing ⚠️
press/runner.py 45.45% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2287      +/-   ##
==========================================
- Coverage   39.91%   39.87%   -0.05%     
==========================================
  Files         372      373       +1     
  Lines       28225    28341     +116     
==========================================
+ Hits        11267    11300      +33     
- Misses      16958    17041      +83     

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

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