From 955ac9e3fcb4d96081d5caff40441acc0e0c0a8e Mon Sep 17 00:00:00 2001 From: Desire Barine Date: Wed, 15 Mar 2023 20:14:34 +0000 Subject: [PATCH] HPE: Fix keyerror seen during volume migration Refactors _get_updated_comments to retrieve updated comment via Volume.get(). This prevents a KeyError when getting comment during volume migration. Closes-Bug: #2008931 Change-Id: Ic0cfa68172d2b0607928b35fec081da96e33c434 --- cinder/volume/drivers/hpe/hpe_3par_common.py | 2 +- ...2008931-hpe-keyerror-on-migration-71d31e6c0a8ab0d9.yaml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-2008931-hpe-keyerror-on-migration-71d31e6c0a8ab0d9.yaml diff --git a/cinder/volume/drivers/hpe/hpe_3par_common.py b/cinder/volume/drivers/hpe/hpe_3par_common.py index ba4d4ea5ceb..971fac3e859 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_common.py +++ b/cinder/volume/drivers/hpe/hpe_3par_common.py @@ -3092,7 +3092,7 @@ class HPE3PARCommon(object): def _get_updated_comment(self, vol_name, **values): vol = self.client.getVolume(vol_name) - comment = json.loads(vol['comment']) if vol['comment'] else {} + comment = json.loads(vol['comment']) if vol.get('comment') else {} comment.update(values) def _update_comment(self, vol_name, **values): diff --git a/releasenotes/notes/bug-2008931-hpe-keyerror-on-migration-71d31e6c0a8ab0d9.yaml b/releasenotes/notes/bug-2008931-hpe-keyerror-on-migration-71d31e6c0a8ab0d9.yaml new file mode 100644 index 00000000000..1e5f09f860f --- /dev/null +++ b/releasenotes/notes/bug-2008931-hpe-keyerror-on-migration-71d31e6c0a8ab0d9.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + HPE 3PAR driver `bug #2008931 + `_: Fixed + issue when performing migrate volume operation when `comment` + attribute is missing from the volume.