Skip to content

Mount refactor#180

Merged
idroz merged 31 commits intobravetools:masterfrom
Szubie:mount-refactor
Oct 13, 2022
Merged

Mount refactor#180
idroz merged 31 commits intobravetools:masterfrom
Szubie:mount-refactor

Conversation

@Szubie
Copy link
Collaborator

@Szubie Szubie commented Oct 13, 2022

Overview

This PR refactors the brave mount and brave umount commands to closer match the behaviour of the mount and umout commands. Several bugs and other issues were fixed along the way.

The biggest change from the perspective of the user comes with how devices are unmounted. Now, instead of having to look for the name of the device that was randomly generated at mount time, the user runs brave umount using the path to the mount-point on the target unit, just like the umount command.

To facilitate easy access to existing mounts, the brave mount command can now list active bravetools-managed mounts similar to the mount command on Linux. When invoked with no arguments, brave mount will list all active mounts across all local units. This new command is needed because brave units now truncates mount paths that are too long - these were breaking the formatting of the table, and undermining the purpose of brave units as a quick snapshot of all relevant info relating to units. This separate command allows for the full paths to be printed without disrupting anything else.

Examples

An example of the new output of brave units (note truncated mount paths, and renaming of "volumes" column to "mounts"):

NAME            STATUS  IPV4            MOUNTS                                                                          PORTS     
test-service    Running 10.67.57.102    /home/ubuntu/volumes/brave_109e3...->/target/testing/really/long/mount...       3000:3000
                                        brave_e7f25c0f8aaa62452feb458b8a...->/target
                                        /home/ubuntu/volumes/brave_fdbcf...->/root
test-service2   Running 10.67.57.79                                                                                     4000:4000

The output of brave mount without args:

Mounts for test-service:
brave_e7f25c0f8aaa62452feb458b8a367ae70cbee551941a35f3c0f26beb on: /target
/home/ubuntu/volumes/brave_109e31d6fd0ff70ede4e60292013146a35a91191d1315a6c4e9dc6e5 on: /target/testing/really/long/mounts/to/see/how/it/looks
/home/ubuntu/volumes/brave_fdbcf07d9cfbbfc60e405bbdbab9cf5eb8535362c31b759cd7b08527 on: /root
Mounts for test-service2:

CLI

The current proposed CLI involves no subcommands and looks like this:

brave mount                                                        #lists all mounts across all units
brave mount <unit_name>                                            #lists all mounts for specific unnit
brave mount <source_path> <unit_name>:<target_path>                #mount host dir on unit
brave mount <unit1_name>:<unit1_path> <unit2_name>:<unit2_path>    #create a volume and mount onto both units

On the whole it looks like it works well, despite overloading the args - there shouldn't be much confusion.

The last command ("create a volume and mount onto both units") sits a bit strangely - it acts differently than expected. It creates a blank new volume and mounts it onto both containers, rather than mounting from source->target as might be assumed. Perhaps that command could benefit more from a subcommand, but it feels a bit redundant just for one command.

Backend

Behind the scenes changes have been made to:

  • Remove chance of accidental collisions in generated device names by using hashes
  • Allow for mounting the same host directory onto multiple units at once on multipass
  • Proper cleanup and error handling
  • Filtering storage pool disks used to launch container since they made output messier

Szubie added 30 commits October 7, 2022 16:43
…ory - if cleanup succeeds, err will be set to nil, causing later panic
…. Prefix with brave_ to make bravetools-mounted devices discoverable later. Benefit of reduced collision probability and ability to find device name in future given the unit name and path.
… cleanup of shared mount of err on mulitpass
…nal logic of trimming leading/trailing slashes if present.
…arlier in process to prevent mismatch between expected device path and actual
…this avoids potential clashes between basenames and also allows mounting the same folder to multiple different mount points
… from output - abstracting away that implementation detail from user, who should operate on paths directly
…volumes onto units. Refactor creation and deletion of these volumes to use the LXD API client - faster, improved error handling and less verbose.
@Szubie
Copy link
Collaborator Author

Szubie commented Oct 13, 2022

A separate PR showing what the CLI might look like with subcommands has been made here, just for ease of comparison: #181

@idroz idroz merged commit 41d86b5 into bravetools:master Oct 13, 2022
@Szubie Szubie deleted the mount-refactor branch October 13, 2022 17:16
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.

2 participants