From 7e10619e6a549456ed923f9c91b3ce3e9e15a597 Mon Sep 17 00:00:00 2001 From: Nikesh Mahalka Date: Fri, 29 Jul 2016 13:52:50 -0400 Subject: [PATCH] Improve snapshot handling in K2 In creating snapshot, we use "Best Effort" retention policy. In this policy snapshot may be deleted in case capacity is running out, causing an inconsistency between K2 state and cinder DB. In order to avoid this inconsistency, add "is_auto_deleteable=False" to the snapshot properties, in order to avoid auto deleting the snapshot. Closes-Bug: #1608488 Change-Id: I70f770ce42ff56314b893a48ff7ed1a46a4ae55f --- cinder/tests/unit/volume/drivers/test_kaminario.py | 8 ++++++++ cinder/volume/drivers/kaminario/kaminario_common.py | 3 ++- .../kaminario-snapshot-auto-delete-ff789c57fa34a7a0.yaml | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/kaminario-snapshot-auto-delete-ff789c57fa34a7a0.yaml diff --git a/cinder/tests/unit/volume/drivers/test_kaminario.py b/cinder/tests/unit/volume/drivers/test_kaminario.py index 6e2ad96346a..7891935625f 100644 --- a/cinder/tests/unit/volume/drivers/test_kaminario.py +++ b/cinder/tests/unit/volume/drivers/test_kaminario.py @@ -157,8 +157,16 @@ class TestKaminarioISCSI(test.TestCase): def test_create_snapshot(self): """Test create_snapshot.""" + self.snap.id = "253b2878-ec60-4793-ad19-e65496ec7aab" + self.driver.client.new = mock.Mock() result = self.driver.create_snapshot(self.snap) self.assertIsNone(result) + fake_object = self.driver.client.search().hits[0] + self.driver.client.new.assert_called_once_with( + "snapshots", + short_name='cs-253b2878-ec60-4793-ad19-e65496ec7aab', + source=fake_object, retention_policy=fake_object, + is_auto_deleteable=False) def test_create_snapshot_with_exception(self): """Test create_snapshot_with_exception.""" diff --git a/cinder/volume/drivers/kaminario/kaminario_common.py b/cinder/volume/drivers/kaminario/kaminario_common.py index 7d4ef60fc6b..66d13889491 100644 --- a/cinder/volume/drivers/kaminario/kaminario_common.py +++ b/cinder/volume/drivers/kaminario/kaminario_common.py @@ -495,7 +495,8 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver): LOG.debug("Creating a snapshot: %(snap)s from vg: %(vg)s", {'snap': snap_name, 'vg': vg_name}) self.client.new("snapshots", short_name=snap_name, - source=vg, retention_policy=rpolicy).save() + source=vg, retention_policy=rpolicy, + is_auto_deleteable=False).save() except Exception as ex: LOG.exception(_LE("Creation of snapshot: %s failed."), snap_name) raise exception.KaminarioCinderDriverException( diff --git a/releasenotes/notes/kaminario-snapshot-auto-delete-ff789c57fa34a7a0.yaml b/releasenotes/notes/kaminario-snapshot-auto-delete-ff789c57fa34a7a0.yaml new file mode 100644 index 00000000000..409c26cbc21 --- /dev/null +++ b/releasenotes/notes/kaminario-snapshot-auto-delete-ff789c57fa34a7a0.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - Add "is_auto_deleteable=False" to the snapshot properties + in Kaminario K2 iSCSI and FC Cinder drivers, in order to + avoid auto deleting the snapshot. +