[lxc-devel] [lxd/master] lxd/storage/cephfs: Cleanups

stgraber on Github lxc-bot at linuxcontainers.org
Wed Jun 26 19:12:45 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190626/3b10ce66/attachment.bin>
-------------- next part --------------
From 4ba67c04cd4404aea877bc9ec16b56fcb97f09cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 26 Jun 2019 15:12:25 -0400
Subject: [PATCH] lxd/storage/cephfs: Cleanups
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>
---
 doc/storage.md        |  2 +-
 lxd/storage_cephfs.go | 61 +++++++++++++++++++++----------------------
 2 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/doc/storage.md b/doc/storage.md
index e00c3289f5..eb9df2a20f 100644
--- a/doc/storage.md
+++ b/doc/storage.md
@@ -17,7 +17,7 @@ ceph.osd.pool\_name             | string    | ceph driver
 ceph.rbd.clone\_copy            | string    | ceph driver                       | true                       | storage\_driver\_ceph              | Whether to use RBD lightweight clones rather than full dataset copies.
 ceph.user.name                  | string    | ceph driver                       | admin                      | storage\_ceph\_user\_name          | The ceph user to use when creating storage pools and volumes.
 cephfs.cluster\_name            | string    | cephfs driver                     | ceph                       | storage\_driver\_cephfs            | Name of the ceph cluster in which to create new storage pools.
-cephfs.path                     | string    | cephfs driver                     | /                          | storage\_driver\_cephfs            | The base path for the CEPH fs mount
+cephfs.path                     | string    | cephfs driver                     | /                          | storage\_driver\_cephfs            | The base path for the CEPHFS mount
 cephfs.user.name                | string    | cephfs driver                     | admin                      | storage\_driver\_cephfs            | The ceph user to use when creating storage pools and volumes.
 lvm.thinpool\_name              | string    | lvm driver                        | LXDThinPool                | storage                            | Thin pool where images and containers are created.
 lvm.use\_thinpool               | bool      | lvm driver                        | true                       | storage\_lvm\_use\_thinpool        | Whether the storage pool uses a thinpool for logical volumes.
diff --git a/lxd/storage_cephfs.go b/lxd/storage_cephfs.go
index f9b6ba9eec..0df8639939 100644
--- a/lxd/storage_cephfs.go
+++ b/lxd/storage_cephfs.go
@@ -81,7 +81,6 @@ func (s *storageCephFs) StoragePoolInit() error {
 	return nil
 }
 
-// Initialize a full storage interface.
 func (s *storageCephFs) StoragePoolCheck() error {
 	return nil
 }
@@ -93,7 +92,7 @@ func (s *storageCephFs) StoragePoolCreate() error {
 	s.pool.Config["volatile.initial_source"] = s.pool.Config["source"]
 
 	if s.pool.Config["source"] == "" {
-		return fmt.Errorf("A ceph fs name OR name/path source is required")
+		return fmt.Errorf("A CEPHFS name or name/path source is required")
 	}
 
 	if s.pool.Config["cephfs.path"] != "" && s.pool.Config["cephfs.path"] != s.pool.Config["source"] {
@@ -121,7 +120,7 @@ func (s *storageCephFs) StoragePoolCreate() error {
 
 	// Check that the filesystem exists
 	if !cephFsExists(s.ClusterName, s.UserName, fsName) {
-		return fmt.Errorf("The requested '%v' CEPH fs doesn't exist", fsName)
+		return fmt.Errorf("The requested '%v' CEPHFS doesn't exist", fsName)
 	}
 
 	// Create a temporary mountpoint
@@ -164,7 +163,7 @@ func (s *storageCephFs) StoragePoolCreate() error {
 	// Check that the existing path is empty
 	ok, _ := shared.PathIsEmpty(filepath.Join(mountPoint, fsPath))
 	if !ok {
-		return fmt.Errorf("Only empty CEPH fs paths can be used as a LXD storage pool")
+		return fmt.Errorf("Only empty CEPHFS paths can be used as a LXD storage pool")
 	}
 
 	// Create the mountpoint for the storage pool.
@@ -174,13 +173,13 @@ func (s *storageCephFs) StoragePoolCreate() error {
 		return err
 	}
 
-	logger.Infof(`Created CEPH fs storage pool "%s" in cluster "%s"`, s.pool.Name, s.ClusterName)
+	logger.Infof(`Created CEPHFS storage pool "%s" in cluster "%s"`, s.pool.Name, s.ClusterName)
 
 	return nil
 }
 
 func (s *storageCephFs) StoragePoolDelete() error {
-	logger.Infof(`Deleting CEPH fs storage pool "%s" in cluster "%s"`, s.pool.Name, s.ClusterName)
+	logger.Infof(`Deleting CEPHFS storage pool "%s" in cluster "%s"`, s.pool.Name, s.ClusterName)
 
 	// Parse the namespace / path
 	fields := strings.SplitN(s.FsName, "/", 2)
@@ -235,7 +234,7 @@ func (s *storageCephFs) StoragePoolDelete() error {
 		// Confirm that the path is now empty
 		ok, _ := shared.PathIsEmpty(filepath.Join(mountPoint, fsPath))
 		if !ok {
-			return fmt.Errorf("Only empty CEPH fs paths can be used as a LXD storage pool")
+			return fmt.Errorf("Only empty CEPHFS paths can be used as a LXD storage pool")
 		}
 
 		// Delete the path itself
@@ -260,10 +259,10 @@ func (s *storageCephFs) StoragePoolDelete() error {
 		if err != nil {
 			return err
 		}
-		logger.Debugf(`Deleted mountpoint "%s" for CEPH fs storage pool "%s" in cluster "%s"`, poolMntPoint, s.FsName, s.ClusterName)
+		logger.Debugf(`Deleted mountpoint "%s" for CEPHFS storage pool "%s" in cluster "%s"`, poolMntPoint, s.FsName, s.ClusterName)
 	}
 
-	logger.Infof(`Deleted CEPH fs storage pool "%s" in cluster "%s"`, s.pool.Name, s.ClusterName)
+	logger.Infof(`Deleted CEPHFS storage pool "%s" in cluster "%s"`, s.pool.Name, s.ClusterName)
 	return nil
 }
 
@@ -365,7 +364,7 @@ func (s *storageCephFs) StoragePoolUmount() (bool, error) {
 	}
 
 	// Unmount
-	err := syscall.Unmount(poolMntPoint, 0)
+	err := tryUnmount(poolMntPoint, syscall.MNT_DETACH)
 	if err != nil {
 		return false, err
 	}
@@ -602,87 +601,87 @@ func (s *storageCephFs) ContainerCreateFromImage(container container, imageFinge
 }
 
 func (s *storageCephFs) ContainerCanRestore(container container, sourceContainer container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerDelete(container container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerCopy(target container, source container, containerOnly bool) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerRefresh(target container, source container, snapshots []container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerMount(c container) (bool, error) {
-	return false, fmt.Errorf("CEPHfs cannot be used for containers")
+	return false, fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerUmount(c container, path string) (bool, error) {
-	return false, fmt.Errorf("CEPHfs cannot be used for containers")
+	return false, fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerRename(container container, newName string) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerRestore(container container, sourceContainer container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerGetUsage(c container) (int64, error) {
-	return -1, fmt.Errorf("CEPHfs cannot be used for containers")
+	return -1, fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerSnapshotCreate(snapshotContainer container, sourceContainer container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerSnapshotCreateEmpty(snapshotContainer container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerSnapshotDelete(snapshotContainer container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerSnapshotRename(snapshotContainer container, newName string) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerSnapshotStart(container container) (bool, error) {
-	return false, fmt.Errorf("CEPHfs cannot be used for containers")
+	return false, fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerSnapshotStop(container container) (bool, error) {
-	return false, fmt.Errorf("CEPHfs cannot be used for containers")
+	return false, fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerBackupCreate(backup backup, source container) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ContainerBackupLoad(info backupInfo, data io.ReadSeeker, tarArgs []string) error {
-	return fmt.Errorf("CEPHfs cannot be used for containers")
+	return fmt.Errorf("CEPHFS cannot be used for containers")
 }
 
 func (s *storageCephFs) ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error {
-	return fmt.Errorf("CEPHfs cannot be used for images")
+	return fmt.Errorf("CEPHFS cannot be used for images")
 }
 
 func (s *storageCephFs) ImageDelete(fingerprint string) error {
-	return fmt.Errorf("CEPHfs cannot be used for images")
+	return fmt.Errorf("CEPHFS cannot be used for images")
 }
 
 func (s *storageCephFs) ImageMount(fingerprint string) (bool, error) {
-	return false, fmt.Errorf("CEPHfs cannot be used for images")
+	return false, fmt.Errorf("CEPHFS cannot be used for images")
 }
 
 func (s *storageCephFs) ImageUmount(fingerprint string) (bool, error) {
-	return false, fmt.Errorf("CEPHfs cannot be used for images")
+	return false, fmt.Errorf("CEPHFS cannot be used for images")
 }
 
 func (s *storageCephFs) MigrationType() migration.MigrationFSType {


More information about the lxc-devel mailing list