Lxd: add snapshot deletion to help

Created on 28 Apr 2016  路  7Comments  路  Source: lxc/lxd

# lxc version
2.0.0

# lxc snapshot --help
Usage: Create a read-only snapshot of a container.

lxc snapshot [remote:]<source> <snapshot name> [--stateful]

Creates a snapshot of the container (optionally with the container's memory
state). When --stateful is used, LXD attempts to checkpoint the container's
running state, including process memory state, TCP connections, etc. so that it
can be restored (via lxc restore) at a later time (although some things, e.g.
TCP connections after the TCP timeout window has expired, may not be restored
successfully).

Example:
lxc snapshot u1 snap0

Most helpful comment

I just got here trying to work out how to delete a snapshot, so I would say a pointer under the snapshot help would be good. Pretty bad for this use-case right now I would say :worried:

I'm also mildly concerned that deleting containers and snapshots is performed with the same command. Not that likely but I can imagine a scenario where someone makes a mistake with autocomplete and accidentally deletes a container instead of the snapshot. Does anyone else think that could be an issue?

All 7 comments

lxc delete is self-explanatory. Do we need help about deleting snapshots in lxc snapshot ?

ishwar@lxdhost:~$ lxc delete --help
Usage: Delete containers or container snapshots.

lxc delete [remote:]<container>[/<snapshot>] [remote:][<container>[/<snapshot>]...]

Destroy containers or snapshots with any attached data (configuration, snapshots, ...).

Options:

    --debug  (= false)
        Enables debug mode.
    -f, --force  (= false)
        Force the removal of stopped containers.
    --force-local  (= false)
        Force using the local unix socket.
    -i, --interactive  (= false)
        Require user confirmation.
    --no-alias  (= false)
        Ignore aliases when determining what command to run.
    --verbose  (= false)
        Enables verbose mode.

Indeed, however it would be great if there was a reference in the snapshot's help.

NB I would like much better if deletion belongs to the functionality accordingly (snapshot for snapshot, image for image etc.).

Well, if we had to point to all the related commands, that help page would become kinda long as we also have:

  • lxc move container/oldsnapname container/newsnapname
  • lxc restore container newsnapname

The main help is also pretty clear:

stgraber@dakara:~$ lxc help | grep delete
delete     - Delete containers or container snapshots.

I disagree, but it's your call:)

I just got here trying to work out how to delete a snapshot, so I would say a pointer under the snapshot help would be good. Pretty bad for this use-case right now I would say :worried:

I'm also mildly concerned that deleting containers and snapshots is performed with the same command. Not that likely but I can imagine a scenario where someone makes a mistake with autocomplete and accidentally deletes a container instead of the snapshot. Does anyone else think that could be an issue?

That actually would be much better to logically organize snapshot commands inside snapshot
as currently it counter-intuitive - i had to double-google how to both list or delete snapshots
having
lxc snapshot create name snapshotname
lxc snapshot delete name/snapshotname
lxc snapshot list [name]
is much much more logical, safer (not possible to delete a stopped vm by accident)
and probably easier to bash-complete, as deletion is not bash-completing.
it is also backward compatible with current syntax (at least partially, when command not overlap with vm name)

I wholeheartedly agree, having just onelined snapshots called "list" of all my containers. Thank god for zfs so they at least don't take any space.

The biggest issue, I think, is that the lxd cli is 50/50 between verb-based and object-based.
config, network, profile, image, file, storage, remote are all objects or object-like, whereas launch, copy, delete, rename, move and exec are verb-based.

Most verbs deal explicitly with containers (start, stop, restart, publish, list) or "general stuff" that either applies to something else or doesn't really do anything if you fuck things up (info, operation, console). "snapshot" is the odd one out, since it's both a verb and an object, so some special treatment should be considered for that one. Especially since my "for c in $(lxc list --format=csv --columns=n; do echo $c; lxc snapshot $c list; done" could've easily filled my drive if I was using directory based storage.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spacekookie picture spacekookie  路  3Comments

kp3nguinz picture kp3nguinz  路  5Comments

jsnjack picture jsnjack  路  3Comments

AndreiPashkin picture AndreiPashkin  路  5Comments

sajoupa picture sajoupa  路  4Comments