From 441442f97f42b7cbb96c18f58e2270e19913749b Mon Sep 17 00:00:00 2001 From: Xiaoqin Li Date: Tue, 6 Dec 2016 16:48:39 +0800 Subject: [PATCH] Storwize: create vol fails near licensed limit The volume creation fails when the virtualized storage capacity that the cluster is using is approaching the virtualized storage capacity that is licensed. The creation is successful in the backend and a warning message is sent to standard error. This change makes the creation success and adds the warning message to log. Change-Id: I95a7a39744d7bb025a47ff60e1a0195d5c4887a7 Closes-Bug: 1645739 --- .../volume/drivers/ibm/test_storwize_svc.py | 23 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 15 +++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index 5f7a4a85d29..c5cd708d2a9 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -5337,6 +5337,7 @@ class StorwizeHelpersTestCase(test.TestCase): self.assertTrue(self.storwize_svc_common.compression_enabled()) +@ddt.ddt class StorwizeSSHTestCase(test.TestCase): def setUp(self): super(StorwizeSSHTestCase, self).setUp() @@ -5377,6 +5378,28 @@ class StorwizeSSHTestCase(test.TestCase): self.storwize_ssh.mkvdiskhostmap, 'HOST3', '9999', 511, True) + @ddt.data((exception.VolumeBackendAPIException(data='CMMVC6372W'), None), + (exception.VolumeBackendAPIException(data='CMMVC6372W'), + {'name': 'fakevol', 'id': '0', 'uid': '0', 'IO_group_id': '0', + 'IO_group_name': 'fakepool'}), + (exception.VolumeBackendAPIException(data='error'), None)) + @ddt.unpack + def test_mkvdisk_with_warning(self, run_ssh_check, lsvol): + opt = {'iogrp': 0} + with mock.patch.object(storwize_svc_common.StorwizeSSH, + 'run_ssh_check_created', + side_effect=run_ssh_check),\ + mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsvdisk', + return_value=lsvol): + if lsvol: + ret = self.storwize_ssh.mkvdisk('fakevol', '1', 'gb', + 'fakepool', opt, []) + self.assertEqual('0', ret) + else: + self.assertRaises(exception.VolumeBackendAPIException, + self.storwize_ssh.mkvdisk, + 'fakevol', '1', 'gb', 'fakepool', opt, []) + class StorwizeSVCReplicationMirrorTestCase(test.TestCase): diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index c5e03e2559a..eedbe4fa14a 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -377,7 +377,20 @@ class StorwizeSSH(object): ssh_cmd = ['svctask', 'mkvdisk', '-name', name, '-mdiskgrp', '"%s"' % pool, '-iogrp', six.text_type(opts['iogrp']), '-size', size, '-unit', units] + params - return self.run_ssh_check_created(ssh_cmd) + try: + return self.run_ssh_check_created(ssh_cmd) + except Exception as ex: + if hasattr(ex, 'msg') and 'CMMVC6372W' in ex.msg: + vdisk = self.lsvdisk(name) + if vdisk: + LOG.warning(_LW('CMMVC6372W The virtualized storage ' + 'capacity that the cluster is using is ' + 'approaching the virtualized storage ' + 'capacity that is licensed.')) + return vdisk['id'] + with excutils.save_and_reraise_exception(): + LOG.exception(_LE('Failed to create vdisk %(vol)s.'), + {'vol': name}) def rmvdisk(self, vdisk, force=True): ssh_cmd = ['svctask', 'rmvdisk']