The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/1774
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 1c1d595f10b44c5ac8dac2f8e61e6d120413ece2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Thu, 17 Mar 2016 15:06:46 -0400 Subject: [PATCH 1/2] Improve error reporting on image POST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1772 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/images.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lxd/images.go b/lxd/images.go index 96a9f8e..b0cef5b 100644 --- a/lxd/images.go +++ b/lxd/images.go @@ -651,9 +651,16 @@ func imagesPost(d *Daemon, r *http.Request) Response { // Is this a container request? post.Seek(0, 0) decoder := json.NewDecoder(post) + imageUpload := false + req := imagePostReq{} err = decoder.Decode(&req) - imageUpload := err != nil + if err != nil { + if r.Header.Get("Content-Type") == "application/json" { + return BadRequest(err) + } + imageUpload = true + } if !imageUpload && !shared.StringInSlice(req.Source["type"], []string{"container", "snapshot", "image", "url"}) { cleanup(builddir, post) From d43a119b8ffcb9e58809c6c4e67209acc066118f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Thu, 17 Mar 2016 15:46:42 -0400 Subject: [PATCH 2/2] Fix error handling logic around snapshots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1768 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/container.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lxd/container.go b/lxd/container.go index e0b02c8..b5bea0e 100644 --- a/lxd/container.go +++ b/lxd/container.go @@ -482,26 +482,18 @@ func containerCreateAsCopy(d *Daemon, args containerArgs, sourceContainer contai } func containerCreateAsSnapshot(d *Daemon, args containerArgs, sourceContainer container) (container, error) { - // Create the snapshot - c, err := containerCreateInternal(d, args) - if err != nil { - return nil, err - } - // Deal with state if args.Stateful { + if !sourceContainer.IsRunning() { + return nil, fmt.Errorf("Container not running, cannot do stateful snapshot") + } + stateDir := sourceContainer.StatePath() - err = os.MkdirAll(stateDir, 0700) + err := os.MkdirAll(stateDir, 0700) if err != nil { - c.Delete() return nil, err } - if !sourceContainer.IsRunning() { - c.Delete() - return nil, fmt.Errorf("Container not running, cannot do stateful snapshot") - } - /* TODO: ideally we would freeze here and unfreeze below after * we've copied the filesystem, to make sure there are no * changes by the container while snapshotting. Unfortunately @@ -520,10 +512,17 @@ func containerCreateAsSnapshot(d *Daemon, args containerArgs, sourceContainer co } if err != nil { + os.RemoveAll(sourceContainer.StatePath()) return nil, err } } + // Create the snapshot + c, err := containerCreateInternal(d, args) + if err != nil { + return nil, err + } + // Clone the container if err := sourceContainer.Storage().ContainerSnapshotCreate(c, sourceContainer); err != nil { c.Delete()
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel