From e2f28b967910625432be0eab6a851adf53ac58ea Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanino Date: Tue, 14 Oct 2014 12:41:41 -0400 Subject: [PATCH] Export cinder volumes only if the status is 'in-use' Currently, cinder volumes are exported both 'in-use' and 'available' after restarting cinder-volume service. This behavior was introduced following commit. commit ffefe18334a9456250e1b6ff88b7b47fb366f374 Author: Zhiteng Huang Date: Sat Aug 23 18:32:57 2014 +0000 If the volumes are attached to nova instances, they should be exported via tgtd after restarting cinder-volume. But the volumes which are not attached to instances must not be exported because everyone can connect these volumes. This patch changes volume export behavior that exports a volume only if the volume status is 'in-use'. Change-Id: I4c598c240b9290c81bd8001e5a0720c8c329aeb9 Signed-off-by: Mitsuhiro Tanino Closes-bug: #1381106 --- cinder/volume/manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index a4ec45123f9..8859807bd8c 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -272,7 +272,8 @@ class VolumeManager(manager.SchedulerDependentManager): self._count_allocated_capacity(ctxt, volume) try: - self.driver.ensure_export(ctxt, volume) + if volume['status'] in ['in-use']: + self.driver.ensure_export(ctxt, volume) except Exception as export_ex: LOG.error(_("Failed to re-export volume %s: " "setting to error state"), volume['id'])