From 107e00e5fb5d97ba33475f08eeef4cc542d74440 Mon Sep 17 00:00:00 2001 From: Stephen Turner Date: Fri, 5 Sep 2014 16:23:22 +0100 Subject: [PATCH] CA-145254 Incorrect error message when try to create CIFS SR with invalid credentials --- XenModel/Actions/StorageLink/SrCreateAction.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/XenModel/Actions/StorageLink/SrCreateAction.cs b/XenModel/Actions/StorageLink/SrCreateAction.cs index 9e2476913..32656d943 100644 --- a/XenModel/Actions/StorageLink/SrCreateAction.cs +++ b/XenModel/Actions/StorageLink/SrCreateAction.cs @@ -163,11 +163,21 @@ namespace XenAdmin.Actions { // Destroy secret after the SR creation is complete. This is safe // since all PBDs will have duplicated the secret (CA-113396). - if (!string.IsNullOrEmpty(secretuuid) && Helpers.CreedenceOrGreater(Connection)) + // + // We do this on a best-effort basis because some types of errors + // mean the secret was never actually created, so the operation will + // fail, masking any earlier error (CA-145254), or causing a successful + // SR.create to be reported as an error. The worst that can happen is + // that an unused secret will be left lying around without warning. + try { - string opaqref = Secret.get_by_uuid(Session, secretuuid); - Secret.destroy(Session, opaqref); + if (!string.IsNullOrEmpty(secretuuid) && Helpers.CreedenceOrGreater(Connection)) + { + string opaqref = Secret.get_by_uuid(Session, secretuuid); + Secret.destroy(Session, opaqref); + } } + catch { } } log.Debug("Checking that SR.create() actually succeeded");