Merge pull request #574 from GaborApatiNagy/master_CA-173497

CA-173497: Thin provisioning: Repair of SR of thin-provisioning on SR hang without return
This commit is contained in:
Mihaela Stoica 2015-07-27 13:12:10 +01:00
commit bfa5db8b40
2 changed files with 44 additions and 2 deletions

View File

@ -32,6 +32,7 @@
using System;
using XenAdmin.Core;
using XenAPI;
using System.Collections.Generic;
namespace XenAdmin.Actions
@ -168,7 +169,37 @@ namespace XenAdmin.Actions
if (SR.PBDs.Count < 1)
return;
foreach (XenRef<PBD> pbd in SR.PBDs)
//CA-176935, CA-173497 - we need to run Unplug for the master last - creating a new list of hosts where the master is always the last
var allPBDRefsToNonMaster = new List<XenRef<PBD>>();
var allPBDRefsToMaster = new List<XenRef<PBD>>();
var master = Helpers.GetMaster(Connection);
foreach (var pbdRef in SR.PBDs)
{
var pbd = Connection.Resolve(pbdRef);
if (pbd != null)
{
if (pbd.host != null)
{
var host = Connection.Resolve(pbd.host);
if (master != null && host != null && host.uuid == master.uuid)
{
allPBDRefsToMaster.Add(pbdRef);
}
else
{
allPBDRefsToNonMaster.Add(pbdRef);
}
}
}
}
var allPBDRefs = new List<XenRef<PBD>>();
allPBDRefs.AddRange(allPBDRefsToNonMaster);
allPBDRefs.AddRange(allPBDRefsToMaster);
foreach (XenRef<PBD> pbd in allPBDRefs)
{
RelatedTask = PBD.async_unplug(Session, pbd.opaque_ref);
PollToCompletion(PercentComplete, PercentComplete + inc);

View File

@ -74,7 +74,18 @@ namespace XenAdmin.Actions
log.Debug("Running SR repair");
log.DebugFormat("SR='{0}'", SR.Name);
foreach (Host host in Connection.Cache.Hosts)
//CA-176935, CA-173497 - we need to run Plug for the master first - creating a new list of hosts where the master is always first
var allHosts = new List<Host>();
var master = Helpers.GetMaster(Connection);
if (master != null)
allHosts.Add(master);
foreach (var host in Connection.Cache.Hosts)
if (!allHosts.Contains(host))
allHosts.Add(host);
foreach (Host host in allHosts)
{
Host stoHost = SR.GetStorageHost();
if (SR.shared