coreos / torus

Torus Distributed Storage
https://coreos.com/blog/torus-distributed-storage-by-coreos.html
Apache License 2.0
1.78k stars 172 forks source link

torusblk: support nbd detach command #321

Closed nak3 closed 8 years ago

barakmich commented 8 years ago

Perhaps you could help explain the desired lifecycle? Right now, as long as the process is running, it is attached, and it detaches on exit.

nak3 commented 8 years ago

Sure. This patch solves two issues:

  1. When we run torusblk nbd <VOLUME> /dev/nbdN as background process, we need to stop the process with kill command.
  2. If torusblk nbd process failed to clean up device during its exit, there are no way to clean up the device by users.

This patch still keep the life cycle, attached during running process and detached during the exit. I am thinking that administrators need this command for above two reason.

barakmich commented 8 years ago

I see. would it be possible to make "attach" the default action for torusblk nbd?

nak3 commented 8 years ago

Sure, I updated. One reason why I wanted to add attach subcommand is that, torusblk nbd's help output conflict with --detach option.

It says that the command need VOLUME, but --detach option needs only NBD-DEV.

Usage:
  torusblk nbd VOLUME [NBD-DEV] [flags]

So, I added the example in Flag output.

Flags:
  -d, --detach string   detach an NBD device from a block volume. (e.g. torsublk nbd -d /dev/nbd0)