From 2c67d2938ff5ac91daeba877dc9739de14418601 Mon Sep 17 00:00:00 2001 From: zhufl Date: Wed, 4 Sep 2019 17:00:03 +0800 Subject: [PATCH] Fix potential NameError of rc_id In create_relationship, if VolumeBackendAPIException is caught and 'CMMVC5959E' is in e, then the exception will not be raised, and then the next state of "if rc_id" will raise NameError exception, so rc_id should be initialized to avoid this potential risk. Change-Id: If8d214c205196c76125a6581c85cbfeee6b4dfbd --- cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py | 1 + cinder/volume/drivers/inspur/instorage/instorage_common.py | 1 + 2 files changed, 2 insertions(+) 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 4f6f026ba5f..335ebf3ed61 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -2124,6 +2124,7 @@ class StorwizeHelpers(object): rc_id = self.ssh.mkrcrelationship(master, aux, system, asyncmirror, cyclingmode) except exception.VolumeBackendAPIException as e: + rc_id = None # CMMVC5959E is the code in Stowize storage, meaning that # there is a relationship that already has this name on the # master cluster. diff --git a/cinder/volume/drivers/inspur/instorage/instorage_common.py b/cinder/volume/drivers/inspur/instorage/instorage_common.py index b7792a0f7bd..e1c759537d1 100644 --- a/cinder/volume/drivers/inspur/instorage/instorage_common.py +++ b/cinder/volume/drivers/inspur/instorage/instorage_common.py @@ -2902,6 +2902,7 @@ class InStorageAssistant(object): rc_id = self.ssh.mkrcrelationship(master, aux, system, asynccopy) except exception.VolumeBackendAPIException as e: + rc_id = None # CMMVC5959E is the code in InStorage, meaning that # there is a relationship that already has this name on the # master cluster.