A drive is composed of one or more BSU which are dynamically created and attached to the VM where bsud
is running.
When drive's target is set to "online", BSUd will maintain the drive available:
- BSUd starts by populating existing BSU on Outscale's cloud with tag
osc.bsud.drive-name
. - BSU matching a drive name will be attached to the VM (if not already attached).
- Once all BSU belonging to a drive are attached, BSUd will initialise each of them as a LVM Physical Volumes (PV) (if not already initialized).
- All PV belonging to a specific drive are then aggregated in a Volume Group (VG) (if not already aggregated).
- A single Logical Volume (LV) will be created (e.g.
/dev/mydrive/bsud
) from the VG and will take 100% of the space (if not already expanded). - A btrfs filesystem will be created on top of the LV (if not already formated).
- Once the filesystem ready, it will be mounted where the user asked (if not already mounted).
- BSU will be created if needed and the whole loop restarts
BSUd is stateless. It will just read configuration and try to converge to desired description using a controller pattern.
Here is a flow chart visualisation of BSUd execution (see drive.rs for more details):
Make a drive offline is a basic reconcile loop with the following steps:
- While fs mounted -> try unmount
- Disable LV
- Disable VG
- Fetch all BSU on Outscale API
- Detach until no BSU is attached
To delete a drive, the reconcile loop is pretty basic too:
- Run Offline reconcile: no drive is now attached
- Fetch all BSU on Outscale API
- Delete all BSU corresponding to the drive on Outscale API
You will need rustlang installed.
You can easily build with just cargo build
or build with musl:
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
./target/x86_64-unknown-linux-musl/release/bsud
If you want to only focus on bsud traces:
sudo RUST_LOG=bsud=trace ./target/debug/bsud -c config.json
For complete traces:
sudo RUST_LOG=trace ./target/debug/bsud -c config.json
If you want to pass your credentials through env variables as root:
sudo OSC_ACCESS_KEY=$OSC_ACCESS_KEY OSC_SECRET_KEY=$OSC_SECRET_KEY RUST_LOG=bsud=trace ./target/debug/bsud -c config.json
TODO
cargo sbom
During dev, it is useful to delete BSU which are previously created.
./tests/delete-drive.sh example
./tests/delete-drive.sh --all
Check test documentation.
Build & run:
cargo build
sudo RUST_LOG=trace OSC_ACCESS_KEY=$OSC_ACCESS_KEY OSC_SECRET_KEY=$OSC_SECRET_KEY ./target/debug/bsud -c docs/config.json
Watch drive (based on a drive named "example")
watch df -B G /dev/mapper/example-bsud
sudo watch vgdisplay example
sudo watch vgs example
Or through a tmux session:
NAME=example; tmux new-session -s bsud-$NAME sudo watch vgs $NAME \; split-window -h watch df -B G /dev/mapper/$NAME-bsud \; split-window -v sudo watch vgdisplay $NAME \; attach
Write some data:
while true; do sudo bash -c 'dd if=/dev/urandom bs=1G count=10 | pv | dd of=/mnt/random${RANDOM}${RANDOM}${RANDOM}${RANDOM}.data'; done
See PV details:
while true; do sudo pvdisplay -S vgname=example -C --separator ' | ' -o pv_name,vg_name,pv_size,vg_size; sleep 2; clear; done