[lxc-devel] [lxd/master] Replace all calls to s.zfsPoolVolumeCreate() with zfsPoolVolumeCreate()
dnegreira on Github
lxc-bot at linuxcontainers.org
Thu Jun 29 20:03:04 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 493 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170629/ffc00257/attachment.bin>
-------------- next part --------------
From 23a328a454d00739206790c6375992d23ea1b854 Mon Sep 17 00:00:00 2001
From: David Negreira <David at otherreality.net>
Date: Thu, 29 Jun 2017 21:59:16 +0200
Subject: [PATCH] removed s.zfsPoolVolumeCreate() changed all
s.zfsPoolVolumeCreate() to use zfsPoolVolumeCreate() added proper logging
error messages
Signed-off-by: David Negreira <David at otherreality.net>
---
lxd/storage_zfs.go | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 822a7d070..cf8a9cbb5 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -188,10 +188,12 @@ func (s *storageZfs) StoragePoolVolumeCreate() error {
logger.Infof("Creating ZFS storage volume \"%s\" on storage pool \"%s\".", s.volume.Name, s.pool.Name)
fs := fmt.Sprintf("custom/%s", s.volume.Name)
+ dataset := fmt.Sprintf("%s/custom/%s", s.pool.Name, s.volume.Name)
customPoolVolumeMntPoint := getStoragePoolVolumeMountPoint(s.pool.Name, s.volume.Name)
- err := s.zfsPoolVolumeCreate(fs)
+ msg, err := zfsPoolVolumeCreate(dataset, "mountpoint=none")
if err != nil {
+ logger.Errorf("failed to create ZFS storage volume \"%s\" on storage pool \"%s\": %s", s.volume.Name, s.pool.Name, msg)
return err
}
revert := true
@@ -527,11 +529,13 @@ func (s *storageZfs) ContainerCreate(container container) error {
containerPath := container.Path()
containerName := container.Name()
fs := fmt.Sprintf("containers/%s", containerName)
+ dataset := fmt.Sprintf("%s/containers/%s", s.pool.Name, containerName)
containerPoolVolumeMntPoint := getContainerMountPoint(s.pool.Name, containerName)
// Create volume.
- err := s.zfsPoolVolumeCreate(fs)
+ msg, err := zfsPoolVolumeCreate(dataset, "mountpoint=none")
if err != nil {
+ logger.Errorf("failed to create ZFS storage volume for container \"%s\" on storage pool \"%s\": %s", s.volume.Name, s.pool.Name, msg)
return err
}
revert := true
@@ -1982,21 +1986,6 @@ func (s *storageZfs) zfsPoolVolumeClone(source string, name string, dest string,
return nil
}
-func (s *storageZfs) zfsPoolVolumeCreate(path string) error {
- poolName := s.getOnDiskPoolName()
- output, err := shared.RunCommand(
- "zfs",
- "create",
- "-p",
- fmt.Sprintf("%s/%s", poolName, path))
- if err != nil {
- logger.Errorf("zfs create failed: %s.", output)
- return fmt.Errorf("Failed to create ZFS filesystem: %s", output)
- }
-
- return nil
-}
-
func (s *storageZfs) zfsFilesystemEntityDelete() error {
var output string
var err error
More information about the lxc-devel
mailing list