From 67ea024c2a91fc79c8f86133b90995b634ee9622 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 3 Jan 2017 10:41:17 -0500 Subject: [PATCH] tgt: Remove existence check before delete This is potentially racy and involves an extraneous exists() check. Just attempt deletion in a safe manner. Change-Id: I96669d61bbb972f411ceb93eaaf9d2c50c75e1ab --- cinder/volume/targets/tgt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cinder/volume/targets/tgt.py b/cinder/volume/targets/tgt.py index 95014138056..8b47c6a63a4 100644 --- a/cinder/volume/targets/tgt.py +++ b/cinder/volume/targets/tgt.py @@ -239,8 +239,8 @@ class TgtAdm(iscsi.ISCSITarget): os.unlink(volume_path) raise exception.ISCSITargetCreateFailed(volume_id=vol_id) - if old_persist_file is not None and os.path.exists(old_persist_file): - os.unlink(old_persist_file) + if old_persist_file is not None: + fileutils.delete_if_exists(old_persist_file) return tid