[lxc-devel] [lxd/master] [JENKINS TEST] lvm improvements
brauner on Github
lxc-bot at linuxcontainers.org
Sat Mar 4 20:21:51 UTC 2017
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/20170304/e0d79d08/attachment.bin>
-------------- next part --------------
From 230c7e91ed82fc0f55331d333194cda4e6ce5aa0 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 4 Mar 2017 21:16:52 +0100
Subject: [PATCH 1/2] lvm: run {pv,vg}scan to ensure consistency
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/storage_lvm.go | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 972bbc3..e70beae 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -498,6 +498,14 @@ func (s *storageLvm) StoragePoolCreate() error {
return fmt.Errorf("Failed to create the volume group for the lvm storage pool: %s.", output)
}
}
+ msg, err := tryExec("pvscan")
+ if err != nil {
+ shared.LogWarnf("Failed to run pvscan: %s.", msg)
+ }
+ msg, err = tryExec("vgscan")
+ if err != nil {
+ shared.LogWarnf("Failed to run vgscan: %s.", msg)
+ }
} else {
s.pool.Config["size"] = ""
if filepath.IsAbs(source) {
From 6b3d34fdc0425860226e9957e537fafce43c79fa Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 4 Mar 2017 21:20:52 +0100
Subject: [PATCH 2/2] test: call pvcreate only once
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
test/main.sh | 2 ++
test/suites/storage.sh | 6 ++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/main.sh b/test/main.sh
index 8f41124..26af724 100755
--- a/test/main.sh
+++ b/test/main.sh
@@ -409,6 +409,7 @@ configure_lvm_loop_device() {
echo "${pvloopdev}" >> "${TEST_DIR}/loops"
pvcreate "${pvloopdev}"
+ pvscan
# The following code enables to return a value from a shell function by
# calling the function as: fun VAR1
@@ -436,6 +437,7 @@ deconfigure_lvm_loop_device() {
SUCCESS=0
# shellcheck disable=SC2034
+ pvscan
for i in $(seq 10); do
pvremove -f "${loopdev}" > /dev/null 2>&1 || true
if losetup -d "${loopdev}"; then
diff --git a/test/suites/storage.sh b/test/suites/storage.sh
index 6b91297..1b676f0 100644
--- a/test/suites/storage.sh
+++ b/test/suites/storage.sh
@@ -60,28 +60,26 @@ test_storage() {
configure_lvm_loop_device loop_file_5 loop_device_5
# shellcheck disable=SC2154
- pvcreate "${loop_device_5}"
# Should fail if vg does not exist, since we have no way of knowing where
# to create the vg without a block device path set.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool10" lvm source=dummy_vg_1 volume.size=25MB
configure_lvm_loop_device loop_file_6 loop_device_6
# shellcheck disable=SC2154
- pvcreate "${loop_device_6}"
vgcreate "lxdtest-$(basename "${LXD_DIR}")-pool11-dummy_vg_2" "${loop_device_6}"
+ vgscan
# Reuse existing volume group "dummy_vg_2" on existing physical volume.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool11" lvm source="lxdtest-$(basename "${LXD_DIR}")-pool11-dummy_vg_2" volume.size=25MB
configure_lvm_loop_device loop_file_7 loop_device_7
# shellcheck disable=SC2154
- pvcreate "${loop_device_7}"
vgcreate "lxdtest-$(basename "${LXD_DIR}")-pool12-dummy_vg_3" "${loop_device_7}"
+ vgscan
# Reuse existing volume group "dummy_vg_3" on existing physical volume.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool12" lvm source="${loop_device_7}" lvm.vg_name="lxdtest-$(basename "${LXD_DIR}")-pool12-dummy_vg_3" volume.size=25MB
configure_lvm_loop_device loop_file_8 loop_device_8
# shellcheck disable=SC2154
- pvcreate "${loop_device_8}"
# Create new volume group "dummy_vg_4" on existing physical volume.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool13" lvm source="${loop_device_8}" lvm.vg_name="lxdtest-$(basename "${LXD_DIR}")-pool13-dummy_vg_4" volume.size=25MB
More information about the lxc-devel
mailing list