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

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 092e6ef603d56b2389d9312d6ba03df02de51628 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 30 Mar 2016 22:52:09 -0400
Subject: [PATCH 1/4] doc: Fix bad markdown
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 doc/configuration.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/configuration.md b/doc/configuration.md
index 7ad2d02..57dfec6 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -23,9 +23,9 @@ core.https\_address             | string        | -           
              | Ad
 core.https\_allowed\_origin     | string        | -                         | 
Access-Control-Allow-Origin http header value
 core.https\_allowed\_methods    | string        | -                         | 
Access-Control-Allow-Methods http header value
 core.https\_allowed\_headers    | string        | -                         | 
Access-Control-Allow-Headers http header value
-core.proxy\_https               | string        | -                         | 
https proxy to use, if any (falls back to HTTPS_PROXY environment variable)
-core.proxy\_http                | string        | -                         | 
http proxy to use, if any (falls back to HTTP_PROXY environment variable)
-core.proxy\_ignore\_hosts       | string        | -                         | 
hosts which don't need the proxy for use (similar format to NO_PROXY, e.g. 
1.2.3.4,1.2.3.5, falls back to NO_PROXY environment varialbe)
+core.proxy\_https               | string        | -                         | 
https proxy to use, if any (falls back to HTTPS\_PROXY environment variable)
+core.proxy\_http                | string        | -                         | 
http proxy to use, if any (falls back to HTTP\_PROXY environment variable)
+core.proxy\_ignore\_hosts       | string        | -                         | 
hosts which don't need the proxy for use (similar format to NO\_PROXY, e.g. 
1.2.3.4,1.2.3.5, falls back to NO\_PROXY environment varialbe)
 core.trust\_password            | string        | -                         | 
Password to be provided by clients to setup a trust
 storage.lvm\_vg\_name           | string        | -                         | 
LVM Volume Group name to be used for container and image storage. A default 
Thin Pool is created using 100% of the free space in the Volume Group, unless 
`storage.lvm_thinpool_name` is set.
 storage.lvm\_thinpool\_name     | string        | "LXDPool"                 | 
LVM Thin Pool to use within the Volume Group specified in 
`storage.lvm_vg_name`, if the default pool parameters are undesirable.

From 03139ff3adf6238c3863595f748fb36f4e358b28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 30 Mar 2016 23:13:25 -0400
Subject: [PATCH 2/4] Apply all templates at container startup time
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #1829

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 doc/configuration.md |  1 +
 lxd/container.go     |  2 ++
 lxd/container_lxc.go | 32 +++++++++++++++++++++++++++++++-
 lxd/storage_btrfs.go |  1 -
 lxd/storage_dir.go   |  1 -
 5 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/doc/configuration.md b/doc/configuration.md
index 57dfec6..e07581f 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -91,6 +91,7 @@ Key                         | Type      | Default       | 
Description
 :--                         | :---      | :------       | :----------
 volatile.\<name\>.hwaddr    | string    | -             | Network device MAC 
address (when no hwaddr property is set on the device itself)
 volatile.\<name\>.name      | string    | -             | Network device name 
(when no name propery is set on the device itself)
+volatile.apply\_template    | string    | -             | The name of a 
template hook which should be triggered upon next startup
 volatile.base\_image        | string    | -             | The hash of the 
image the container was created from, if any.
 volatile.last\_state.idmap  | string    | -             | Serialized container 
uid/gid map
 volatile.last\_state.power  | string    | -             | Container state as 
of last host shutdown
diff --git a/lxd/container.go b/lxd/container.go
index b5bea0e..5e216a6 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -75,6 +75,8 @@ func containerValidConfigKey(k string) bool {
                return true
        case "raw.lxc":
                return true
+       case "volatile.apply_template":
+               return true
        case "volatile.base_image":
                return true
        case "volatile.last_state.idmap":
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index fea46bc..b78a77a 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1233,7 +1233,24 @@ func (c *containerLXC) OnStart() error {
        }
 
        // Template anything that needs templating
-       err = c.TemplateApply("start")
+       key := "volatile.apply_template"
+       if c.localConfig[key] != "" {
+               // Run any template that needs running
+               err = c.templateApplyNow(c.localConfig[key])
+               if err != nil {
+                       c.StorageStop()
+                       return err
+               }
+
+               // Remove the volatile key from the DB
+               err := dbContainerConfigRemove(c.daemon.db, c.id, key)
+               if err != nil {
+                       c.StorageStop()
+                       return err
+               }
+       }
+
+       err = c.templateApplyNow("start")
        if err != nil {
                c.StorageStop()
                return err
@@ -2641,6 +2658,19 @@ func (c *containerLXC) Checkpoint(opts 
lxc.CheckpointOptions) error {
 }
 
 func (c *containerLXC) TemplateApply(trigger string) error {
+       // "create" and "copy" are deferred until next start
+       if shared.StringInSlice(trigger, []string{"create", "copy"}) {
+               // The two events are mutually exclusive so only keep the last 
one
+               err := c.ConfigKeySet("volatile.apply_template", trigger)
+               if err != nil {
+                       return err
+               }
+       }
+
+       return c.templateApplyNow(trigger)
+}
+
+func (c *containerLXC) templateApplyNow(trigger string) error {
        // If there's no metadata, just return
        fname := filepath.Join(c.Path(), "metadata.yaml")
        if !shared.PathExists(fname) {
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index e648e90..2c2779d 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -193,7 +193,6 @@ func (s *storageBtrfs) ContainerRename(container container, 
newName string) erro
                }
        }
 
-       // TODO: No TemplateApply here?
        return nil
 }
 
diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go
index f89b545..652d7eb 100644
--- a/lxd/storage_dir.go
+++ b/lxd/storage_dir.go
@@ -144,7 +144,6 @@ func (s *storageDir) ContainerRename(container container, 
newName string) error
                }
        }
 
-       // TODO: No TemplateApply here?
        return nil
 }
 

From a9935eb239b99245e94ddfd00016059f94b5cbe1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 30 Mar 2016 23:20:50 -0400
Subject: [PATCH 3/4] simplestreams: cleanup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 - Drop backward compatibility code
 - Drop the "serial" aliases as those were more confusing than useful

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 shared/simplestreams.go | 77 -------------------------------------------------
 1 file changed, 77 deletions(-)

diff --git a/shared/simplestreams.go b/shared/simplestreams.go
index 4588859..ab2d540 100644
--- a/shared/simplestreams.go
+++ b/shared/simplestreams.go
@@ -364,11 +364,6 @@ func (s *SimpleStreams) applyAliases(images []ImageInfo) 
([]ImageInfo, map[strin
                                        if alias != nil {
                                                image.Aliases = 
append(image.Aliases, *alias)
                                        }
-
-                                       alias = addAlias(fmt.Sprintf("%s/%s", 
entry, image.Properties["serial"]), image.Fingerprint)
-                                       if alias != nil {
-                                               image.Aliases = 
append(image.Aliases, *alias)
-                                       }
                                }
 
                                // Medium
@@ -376,78 +371,6 @@ func (s *SimpleStreams) applyAliases(images []ImageInfo) 
([]ImageInfo, map[strin
                                if alias != nil {
                                        image.Aliases = append(image.Aliases, 
*alias)
                                }
-
-                               // Long
-                               alias = addAlias(fmt.Sprintf("%s/%s/%s", entry, 
image.Properties["architecture"], image.Properties["serial"]), 
image.Fingerprint)
-                               if alias != nil {
-                                       image.Aliases = append(image.Aliases, 
*alias)
-                               }
-                       }
-               } else {
-                       // FIXME: This is backward compatibility needed until 
cloud-images.ubuntu.com supports the aliases field
-                       // Short
-                       if image.Architecture == architectureName {
-                               alias := addAlias(fmt.Sprintf("%s/%s", 
image.Properties["os"], image.Properties["release"]), image.Fingerprint)
-                               if alias != nil {
-                                       image.Aliases = append(image.Aliases, 
*alias)
-                               }
-
-                               alias = addAlias(fmt.Sprintf("%s/%s/%s", 
image.Properties["os"], image.Properties["release"], 
image.Properties["serial"]), image.Fingerprint)
-                               if alias != nil {
-                                       image.Aliases = append(image.Aliases, 
*alias)
-                               }
-
-                               alias = addAlias(fmt.Sprintf("%s/%c", 
image.Properties["os"], image.Properties["release"][0]), image.Fingerprint)
-                               if alias != nil {
-                                       image.Aliases = append(image.Aliases, 
*alias)
-                               }
-
-                               alias = addAlias(fmt.Sprintf("%s/%c/%s", 
image.Properties["os"], image.Properties["release"][0], 
image.Properties["serial"]), image.Fingerprint)
-                               if alias != nil {
-                                       image.Aliases = append(image.Aliases, 
*alias)
-                               }
-
-                               alias = addAlias(fmt.Sprintf("%s/%s", 
image.Properties["os"], image.Properties["version"]), image.Fingerprint)
-                               if alias != nil {
-                                       image.Aliases = append(image.Aliases, 
*alias)
-                               }
-
-                               alias = addAlias(fmt.Sprintf("%s/%s/%s", 
image.Properties["os"], image.Properties["version"], 
image.Properties["serial"]), image.Fingerprint)
-                               if alias != nil {
-                                       image.Aliases = append(image.Aliases, 
*alias)
-                               }
-                       }
-
-                       // Medium
-                       alias := addAlias(fmt.Sprintf("%s/%s/%s", 
image.Properties["os"], image.Properties["release"], 
image.Properties["architecture"]), image.Fingerprint)
-                       if alias != nil {
-                               image.Aliases = append(image.Aliases, *alias)
-                       }
-
-                       alias = addAlias(fmt.Sprintf("%s/%c/%s", 
image.Properties["os"], image.Properties["release"][0], 
image.Properties["architecture"]), image.Fingerprint)
-                       if alias != nil {
-                               image.Aliases = append(image.Aliases, *alias)
-                       }
-
-                       alias = addAlias(fmt.Sprintf("%s/%s/%s", 
image.Properties["os"], image.Properties["version"], 
image.Properties["architecture"]), image.Fingerprint)
-                       if alias != nil {
-                               image.Aliases = append(image.Aliases, *alias)
-                       }
-
-                       // Long
-                       alias = addAlias(fmt.Sprintf("%s/%s/%s/%s", 
image.Properties["os"], image.Properties["release"], 
image.Properties["architecture"], image.Properties["serial"]), 
image.Fingerprint)
-                       if alias != nil {
-                               image.Aliases = append(image.Aliases, *alias)
-                       }
-
-                       alias = addAlias(fmt.Sprintf("%s/%c/%s/%s", 
image.Properties["os"], image.Properties["release"][0], 
image.Properties["architecture"], image.Properties["serial"]), 
image.Fingerprint)
-                       if alias != nil {
-                               image.Aliases = append(image.Aliases, *alias)
-                       }
-
-                       alias = addAlias(fmt.Sprintf("%s/%s/%s/%s", 
image.Properties["os"], image.Properties["version"], 
image.Properties["architecture"], image.Properties["serial"]), 
image.Fingerprint)
-                       if alias != nil {
-                               image.Aliases = append(image.Aliases, *alias)
                        }
                }
 

From 5e572c22c361449b7a706ba9901e38fa79c2d973 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 30 Mar 2016 23:37:53 -0400
Subject: [PATCH 4/4] lvm: Allow setting volume size
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We had an environment variable knob for our testsuite, but since there
is user demand for it, lets make it official.

This also simplifies some of the existing code.

Closes #1824

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 doc/configuration.md |  1 +
 doc/environment.md   |  1 -
 lxd/api_1.0.go       |  5 -----
 lxd/daemon.go        |  2 ++
 lxd/storage_lvm.go   | 15 +++++----------
 test/backends/lvm.sh |  2 +-
 6 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/doc/configuration.md b/doc/configuration.md
index e07581f..a3e3b2c 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -30,6 +30,7 @@ core.trust\_password            | string        | -           
              | Pa
 storage.lvm\_vg\_name           | string        | -                         | 
LVM Volume Group name to be used for container and image storage. A default 
Thin Pool is created using 100% of the free space in the Volume Group, unless 
`storage.lvm_thinpool_name` is set.
 storage.lvm\_thinpool\_name     | string        | "LXDPool"                 | 
LVM Thin Pool to use within the Volume Group specified in 
`storage.lvm_vg_name`, if the default pool parameters are undesirable.
 storage.lvm\_fstype             | string        | ext4                      | 
Format LV with filesystem, for now it's value can be only ext4 (default) or xfs.
+storage.lvm\_volume\_size       | string        | 10GiB                     | 
Size of the logical volume
 storage.zfs\_pool\_name         | string        | -                         | 
ZFS pool name
 images.compression\_algorithm   | string        | gzip                      | 
Compression algorithm to use for new images (bzip2, gzip, lzma, xz or none)
 images.remote\_cache\_expiry    | integer       | 10                        | 
Number of days after which an unused cached remote image will be flushed
diff --git a/doc/environment.md b/doc/environment.md
index 02823ec..d63befc 100644
--- a/doc/environment.md
+++ b/doc/environment.md
@@ -20,4 +20,3 @@ Name                            | Description
 :---                            | :----
 LXD\_SECURITY\_APPARMOR         | If set to "false", forces AppArmor off
 LXD\_LXC\_TEMPLATE\_CONFIG      | Path to the LXC template configuration 
directory
-LXD\_LVM\_LVSIZE                | Size of the default LVM LV (10Gib by default)
diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go
index e098e0f..2467e33 100644
--- a/lxd/api_1.0.go
+++ b/lxd/api_1.0.go
@@ -211,11 +211,6 @@ func api10Put(d *Daemon, r *http.Request) Response {
                        if err != nil {
                                return InternalError(err)
                        }
-               } else if key == "storage.lvm_fstype" {
-                       err := storageLVMSetFsTypeConfig(d, value.(string))
-                       if err != nil {
-                               return InternalError(err)
-                       }
                } else if key == "storage.zfs_pool_name" {
                        err := storageZFSSetPoolNameConfig(d, value.(string))
                        if err != nil {
diff --git a/lxd/daemon.go b/lxd/daemon.go
index becbdb6..6fc384d 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -1113,6 +1113,8 @@ func (d *Daemon) ConfigKeyIsValid(key string) bool {
                return true
        case "storage.lvm_fstype":
                return true
+       case "storage.lvm_volume_size":
+               return true
        case "storage.zfs_pool_name":
                return true
        case "images.remote_cache_expiry":
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index f37ef0d..58eb02e 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -161,15 +161,6 @@ func storageLVMSetVolumeGroupNameConfig(d *Daemon, vgname 
string) error {
        return nil
 }
 
-func storageLVMSetFsTypeConfig(d *Daemon, fstype string) error {
-       err := d.ConfigValueSet("storage.lvm_fstype", fstype)
-       if err != nil {
-               return err
-       }
-
-       return nil
-}
-
 func xfsGenerateNewUUID(lvpath string) error {
        output, err := exec.Command(
                "xfs_admin",
@@ -952,7 +943,11 @@ func (s *storageLvm) createThinLV(lvname string) (string, 
error) {
                }
        }
 
-       lvSize := os.Getenv("LXD_LVM_LVSIZE")
+       lvSize, err := s.d.ConfigValueGet("storage.lvm_volume_size")
+       if err != nil {
+               return "", fmt.Errorf("Error checking server config, err=%v", 
err)
+       }
+
        if lvSize == "" {
                lvSize = storageLvmDefaultThinLVSize
        }
diff --git a/test/backends/lvm.sh b/test/backends/lvm.sh
index 2734e68..0996e0a 100644
--- a/test/backends/lvm.sh
+++ b/test/backends/lvm.sh
@@ -28,7 +28,7 @@ lvm_configure() {
 
   echo "==> Configuring lvm backend in ${LXD_DIR}"
 
-  export LXD_LVM_LVSIZE="10Mib"
+  lxc config set storage.lvm_volume_size "10Mib"
   lxc config set storage.lvm_vg_name "lxdtest-$(basename "${LXD_DIR}")"
 }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to