The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3000

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) ===
Closes #2999

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 8ced01c7105317dbc3f0eb72d506f5baa4491bac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Thu, 2 Mar 2017 16:52:58 -0500
Subject: [PATCH] Fix base image tracking
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #2999

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/container.go       |  3 +++
 lxd/containers_post.go | 13 +++----------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/lxd/container.go b/lxd/container.go
index bf8d297..06939e5 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -545,6 +545,9 @@ func containerCreateFromImage(d *Daemon, args 
containerArgs, hash string) (conta
                }
        }
 
+       // Set the BaseImage field (regardless of previous value)
+       args.BaseImage = hash
+
        // Create the container
        c, err := containerCreateInternal(d, args)
        if err != nil {
diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 3425818..96918d4 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -48,8 +48,8 @@ func createFromImage(d *Daemon, req *api.ContainersPost) 
Response {
 
                var image *api.Image
 
-               for _, hash := range hashes {
-                       _, img, err := dbImageGet(d.db, hash, false, true)
+               for _, imageHash := range hashes {
+                       _, img, err := dbImageGet(d.db, imageHash, false, true)
                        if err != nil {
                                continue
                        }
@@ -84,7 +84,6 @@ func createFromImage(d *Daemon, req *api.ContainersPost) 
Response {
 
        run := func(op *operation) error {
                args := containerArgs{
-                       BaseImage: hash,
                        Config:    req.Config,
                        Ctype:     cTypeRegular,
                        Devices:   req.Devices,
@@ -94,10 +93,6 @@ func createFromImage(d *Daemon, req *api.ContainersPost) 
Response {
                }
 
                if req.Source.Server != "" {
-                       if args.Profiles == nil {
-                               args.Profiles = []string{"default"}
-                       }
-
                        hash, err = d.ImageDownload(
                                op, req.Source.Server, req.Source.Protocol, 
req.Source.Certificate, req.Source.Secret,
                                hash, true, 
daemonConfig["images.auto_update_cached"].GetBool(), "")
@@ -111,14 +106,12 @@ func createFromImage(d *Daemon, req *api.ContainersPost) 
Response {
                        return err
                }
 
-               hash = imgInfo.Fingerprint
-
                args.Architecture, err = 
osarch.ArchitectureId(imgInfo.Architecture)
                if err != nil {
                        return err
                }
 
-               _, err = containerCreateFromImage(d, args, hash)
+               _, err = containerCreateFromImage(d, args, imgInfo.Fingerprint)
                return err
        }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to