[lxc-devel] [lxd/master] Fix container quotas on CEPH

stgraber on Github lxc-bot at linuxcontainers.org
Sat Aug 11 03:27:33 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180811/1e26eb9a/attachment.bin>
-------------- next part --------------
From 14a0f890e66f8a0fe2ac9e8e123af53825ab444e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 10 Aug 2018 23:26:27 -0400
Subject: [PATCH 1/2] lxc/container: CEPH also needs offline quotas
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/container.go b/lxd/container.go
index f7b2fb277..8ac7374b1 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -1123,7 +1123,7 @@ func containerConfigureInternal(c container) error {
 	storage := c.Storage()
 	if rootDiskDevice["size"] != "" {
 		storageTypeName := storage.GetStorageTypeName()
-		if storageTypeName == "lvm" && c.IsRunning() {
+		if (storageTypeName == "lvm" || storageTypeName == "ceph") && c.IsRunning() {
 			err = c.ConfigKeySet("volatile.apply_quota", rootDiskDevice["size"])
 			if err != nil {
 				return err

From 23ece19eac423abc06ab79a313dc1c1a9c174ce0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 10 Aug 2018 23:26:44 -0400
Subject: [PATCH 2/2] lxd/storage/ceph: Fix default container quotas
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4899

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_ceph.go | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index b9c14c507..15b6c6ce9 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -420,7 +420,7 @@ func (s *storageCeph) StoragePoolVolumeCreate() error {
 		}
 	}()
 
-	// apply quota
+	// Apply quota
 	if s.volume.Config["size"] != "" {
 		size, err := shared.ParseByteSizeString(s.volume.Config["size"])
 		if err != nil {
@@ -880,6 +880,28 @@ func (s *storageCeph) ContainerCreateFromImage(container container, fingerprint
 		}
 	}()
 
+	// Apply quota
+	_, imageVol, err := s.s.Cluster.StoragePoolNodeVolumeGetType(fingerprint, db.StoragePoolVolumeTypeImage, s.poolID)
+	if err != nil {
+		return err
+	}
+
+	if s.volume.Config["size"] != "" && imageVol.Config["size"] != s.volume.Config["size"] {
+		size, err := shared.ParseByteSizeString(s.volume.Config["size"])
+		if err != nil {
+			return err
+		}
+
+		newSize := s.volume.Config["size"]
+		s.volume.Config["size"] = imageVol.Config["size"]
+		err = s.StorageEntitySetQuota(storagePoolVolumeTypeContainer, size, container)
+		if err != nil {
+			return err
+		}
+		s.volume.Config["size"] = newSize
+	}
+
+	// Shift if needed
 	ourMount, err := s.ContainerMount(container)
 	if err != nil {
 		return err


More information about the lxc-devel mailing list