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

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 67df1839e482e854fe22b89badf2dbf8f24d0e07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 27 Mar 2019 18:56:47 -0400
Subject: [PATCH 1/2] lxd: Drop initialShiftRootfs and always shift on start
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/container_lxc.go  |  4 ++--
 lxd/storage_btrfs.go  |  8 --------
 lxd/storage_ceph.go   | 23 -----------------------
 lxd/storage_dir.go    |  7 -------
 lxd/storage_lvm.go    |  7 -------
 lxd/storage_shared.go | 28 ----------------------------
 lxd/storage_zfs.go    |  7 -------
 7 files changed, 2 insertions(+), 82 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 32b6baa790..f3b8b5f8a0 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -449,9 +449,9 @@ func containerLXCCreate(s *state.State, args 
db.ContainerArgs) (container, error
        // Invalid idmap cache
        c.idmapset = nil
 
-       // Set last_state to the map we have on disk
+       // Set last_state if not currently set
        if c.localConfig["volatile.last_state.idmap"] == "" {
-               err = c.ConfigKeySet("volatile.last_state.idmap", jsonIdmap)
+               err = c.ConfigKeySet("volatile.last_state.idmap", "[]")
                if err != nil {
                        c.Delete()
                        logger.Error("Failed creating container", ctxMap)
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 2c2fee436a..a1b3a8aed7 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -944,14 +944,6 @@ func (s *storageBtrfs) ContainerCreateFromImage(container 
container, fingerprint
                return errors.Wrap(err, "Failed to create container mountpoint")
        }
 
-       if !container.IsPrivileged() {
-               err := s.initialShiftRootfs(container, nil)
-               if err != nil {
-                       s.ContainerDelete(container)
-                       return errors.Wrap(err, "Failed to shift rootfs")
-               }
-       }
-
        logger.Debugf("Created BTRFS storage volume for container \"%s\" on 
storage pool \"%s\"", s.volume.Name, s.pool.Name)
        err = container.TemplateApply("create")
        if err != nil {
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index a626b4367d..8e99ff126a 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -972,29 +972,6 @@ func (s *storageCeph) ContainerCreateFromImage(container 
container, fingerprint
                defer s.ContainerUmount(container, containerPath)
        }
 
-       if !privileged {
-               err := s.initialShiftRootfs(container, nil)
-               if err != nil {
-                       logger.Errorf(`Failed to shift rootfs for container 
"%s": %s`, containerName, err)
-                       return err
-               }
-               logger.Debugf(`Shifted rootfs for container "%s"`, 
containerName)
-
-               err = os.Chmod(containerPoolVolumeMntPoint, 0711)
-               if err != nil {
-                       logger.Errorf(`Failed change mountpoint "%s" 
permissions to 0711 for container "%s" for RBD storage volume: %s`, 
containerPoolVolumeMntPoint, containerName, err)
-                       return err
-               }
-               logger.Debugf(`Changed mountpoint "%s" permissions to 0711 for 
container "%s" for RBD storage volume`, containerPoolVolumeMntPoint, 
containerName)
-       } else {
-               err := os.Chmod(containerPoolVolumeMntPoint, 0700)
-               if err != nil {
-                       logger.Errorf(`Failed change mountpoint "%s" 
permissions to 0700 for container "%s" for RBD storage volume: %s`, 
containerPoolVolumeMntPoint, containerName, err)
-                       return err
-               }
-               logger.Debugf(`Changed mountpoint "%s" permissions to 0700 for 
container "%s" for RBD storage volume`, containerPoolVolumeMntPoint, 
containerName)
-       }
-
        err = container.TemplateApply("create")
        if err != nil {
                logger.Errorf(`Failed to apply create template for container 
"%s": %s`, containerName, err)
diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go
index f82e821b26..2b29832f65 100644
--- a/lxd/storage_dir.go
+++ b/lxd/storage_dir.go
@@ -548,13 +548,6 @@ func (s *storageDir) ContainerCreateFromImage(container 
container, imageFingerpr
                return errors.Wrap(err, "Unpack image")
        }
 
-       if !privileged {
-               err := s.initialShiftRootfs(container, nil)
-               if err != nil {
-                       return errors.Wrap(err, "Shift rootfs")
-               }
-       }
-
        err = container.TemplateApply("create")
        if err != nil {
                return errors.Wrap(err, "Apply template")
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 34d521c985..e9053d762a 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -1059,13 +1059,6 @@ func (s *storageLvm) ContainerCreateFromImage(container 
container, fingerprint s
                return errors.Wrap(err, "Set mount point permissions")
        }
 
-       if !container.IsPrivileged() {
-               err := s.initialShiftRootfs(container, nil)
-               if err != nil {
-                       return errors.Wrap(err, "Shift rootfs")
-               }
-       }
-
        err = container.TemplateApply("create")
        if err != nil {
                logger.Errorf("Error in create template during 
ContainerCreateFromImage, continuing to unmount: %s", err)
diff --git a/lxd/storage_shared.go b/lxd/storage_shared.go
index ae7d7ee771..8fb89b2da6 100644
--- a/lxd/storage_shared.go
+++ b/lxd/storage_shared.go
@@ -1,13 +1,8 @@
 package main
 
 import (
-       "fmt"
-       "os"
-
        "github.com/lxc/lxd/lxd/state"
        "github.com/lxc/lxd/shared/api"
-       "github.com/lxc/lxd/shared/logger"
-       "github.com/pkg/errors"
 )
 
 type storageShared struct {
@@ -35,29 +30,6 @@ func (s *storageShared) GetStorageTypeVersion() string {
        return s.sTypeVersion
 }
 
-func (s *storageShared) initialShiftRootfs(c container, skipper func(dir 
string, absPath string, fi os.FileInfo) bool) error {
-       rpath := c.RootfsPath()
-
-       logger.Debugf("Shifting root filesystem \"%s\" for \"%s\"", rpath, 
c.Name())
-
-       idmapset, err := c.IdmapSet()
-       if err != nil {
-               return errors.Wrap(err, "Get ID map")
-       }
-
-       if idmapset == nil {
-               return fmt.Errorf("IdmapSet of container '%s' is nil", c.Name())
-       }
-
-       err = idmapset.ShiftRootfs(rpath, skipper)
-       if err != nil {
-               logger.Debugf("Shift of rootfs %s failed: %s", rpath, err)
-               return errors.Wrap(err, "Shift rootfs")
-       }
-
-       return nil
-}
-
 func (s *storageShared) createImageDbPoolVolume(fingerprint string) error {
        // Fill in any default volume config.
        volumeConfig := map[string]string{}
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index a678121c7e..0a01d16c74 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -919,13 +919,6 @@ func (s *storageZfs) ContainerCreateFromImage(container 
container, fingerprint s
                return err
        }
 
-       if !privileged {
-               err = s.initialShiftRootfs(container, zfsIdmapSetSkipper)
-               if err != nil {
-                       return err
-               }
-       }
-
        err = container.TemplateApply("create")
        if err != nil {
                return err

From 19a68fab6e7d83ddd186ac3faa31625566320c5e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 27 Mar 2019 19:12:05 -0400
Subject: [PATCH 2/2] lxc/launch: Show start progress
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxc/launch.go | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lxc/launch.go b/lxc/launch.go
index 2f51cea8c5..cdb7b786f4 100644
--- a/lxc/launch.go
+++ b/lxc/launch.go
@@ -5,6 +5,7 @@ import (
 
        "github.com/spf13/cobra"
 
+       "github.com/lxc/lxd/lxc/utils"
        "github.com/lxc/lxd/shared/api"
        cli "github.com/lxc/lxd/shared/cmd"
        "github.com/lxc/lxd/shared/i18n"
@@ -74,8 +75,19 @@ func (c *cmdLaunch) Run(cmd *cobra.Command, args []string) 
error {
                return err
        }
 
-       err = op.Wait()
+       progress := utils.ProgressRenderer{
+               Quiet: c.global.flagQuiet,
+       }
+       _, err = op.AddHandler(progress.UpdateOp)
+       if err != nil {
+               progress.Done("")
+               return err
+       }
+
+       // Wait for operation to finish
+       err = utils.CancelableWait(op, &progress)
        if err != nil {
+               progress.Done("")
                prettyName := name
                if remote != "" {
                        prettyName = fmt.Sprintf("%s:%s", remote, name)
@@ -84,5 +96,6 @@ func (c *cmdLaunch) Run(cmd *cobra.Command, args []string) 
error {
                return fmt.Errorf("%s\n"+i18n.G("Try `lxc info --show-log %s` 
for more info"), err, prettyName)
        }
 
+       progress.Done("")
        return nil
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to