Repository navigation
fix(storage): look at the device before erasing or unmounting it - #29
Merged
Merged
Conversation
The dashboard offers only the disks that are free, but its list may be old. The routes that erase or unmount now look at the device themselves, before anything is done to it. - EraseRefusal: a new storage is made of a whole disk that holds nothing in use; a storage formatted again is mounted where this box mounts one, and is not a part of the merged storage. - UnmountRefusal: removing a storage unmounts only what is mounted under /media or /mnt. - A path that is not a block device is a 400, a device in use a 409. - PublishEvent: when the message bus does not answer there is no response to read; the event is logged as lost and the service goes on. - UmountUSB runs the helper through bash with the mount point as one argument, and returns what udevil said.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The dashboard offers only the disks that are free, but its list may be old. With this change the routes that erase or unmount look at the device themselves, just before they do anything to it.
POST /v1/storage) takes a whole disk that holds nothing in use: no mounted filesystem, no member of an array, a volume group, a pool or an encrypted volume. Without the format nothing is erased, and the disk's filesystem is mounted as before.PUT /v1/storage) takes a storage: a device mounted where this box mounts one (/media, or/mntfor older installs). It may be a partition, an array or a logical volume. A storage the merged storage is made of must be taken out of it first.DELETE /v1/storage,DELETE /v1/disks/umount) unmounts only what is mounted under/mediaor/mnt, on the device or below it.lsblkanswers 400. A device in use answers 409, with the reason. In both cases nothing has been unmounted or erased.PublishEventreturns when the bus does not answer, in place of reading a response that is not there. The check at start-up uses it too.UmountUSBrunslocal-storage-helper.shthrough bash, with the mount point as one argument; the helper quotes it. The error it returns carries whatudevilsaid.Tests.
route/v1/storage_erase_test.godescribes the disks of a box (system disk, array member, volume group, open encrypted volume, storages on a partition, an array and a logical volume, a blank disk) and checks, route by route, what is refused with nothing done and what goes on.service/publish_test.gocovers a bus that does not answer,service/disk_umount_usb_test.gowhat the helper receives.go vet ./...andgo test ./...pass in agolang:1.26container. No real disk was formatted or ejected.