CA-337280: Creation of GFS2 SRs with CHAP authentication is not supported.

This is also a better fix for CA-335356.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2020-04-28 03:43:36 +01:00 committed by Mihaela Stoica
parent 5927d52349
commit 8d6686b63f
10 changed files with 93 additions and 57 deletions

View File

@ -329,7 +329,7 @@ namespace XenAdmin.Wizards.DRWizards
try
{
var metadataSrs = SR.ParseSRListXML(srProbeAction.Result);
var metadataSrs = srProbeAction.SRs ?? new List<SR.SRInfo>();
if (ScannedDevices.ContainsKey(deviceId))
{

View File

@ -167,7 +167,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
if (!action.Succeeded)
return;
List<SR.SRInfo> SRs = SR.ParseSRListXML(action.Result);
var SRs = action.SRs ?? new List<SR.SRInfo>();
if (SRs.Count == 0)
{
// Disable box

View File

@ -204,31 +204,13 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
private bool RunProbe(Host master, FibreChannelDescriptor srDescriptor, out List<SR.SRInfo> srs)
{
srs = new List<SR.SRInfo>();
var action = new SrProbeAction(Connection, master, srDescriptor.SrType, srDescriptor.DeviceConfig);
using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
dlg.ShowDialog(this);
if (action.Succeeded)
{
try
{
srs = action.ProbeExtResult != null ? SR.ParseSRList(action.ProbeExtResult) : SR.ParseSRListXML(action.Result);
return true;
}
catch
{
//ignore
}
}
//CA-335356 special treatment of case where gfs2 cannot see the same devices as lvmohba
if (srDescriptor.SrType == SR.SRTypes.gfs2 && action.Exception is Failure f && f.ErrorDescription.Count > 1 &&
f.ErrorDescription[0].StartsWith("SR_BACKEND_FAILURE") && f.ErrorDescription[1] == "DeviceNotFoundException")
return true;
return false;
srs = action.SRs ?? new List<SR.SRInfo>();
return action.Succeeded;
}
public override bool EnableNext()

View File

@ -106,7 +106,10 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
HelpersGUI.PerformIQNCheck();
if (direction == PageLoadedDirection.Forward)
{
textBoxIscsiHost.Focus();
ResetAll();
}
}
protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
@ -175,7 +178,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
private bool RunProbe(Host master, SR.SRTypes srType, out List<SR.SRInfo> srs)
{
srs = null;
srs = new List<SR.SRInfo>();
var dconf = GetDeviceConfig(srType);
if (dconf == null)
@ -185,18 +188,10 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee) {ShowCancel = true})
dialog.ShowDialog(this);
srs = action.SRs ?? new List<SR.SRInfo>();
if (action.Succeeded)
{
try
{
srs = action.ProbeExtResult != null ? SR.ParseSRList(action.ProbeExtResult) : SR.ParseSRListXML(action.Result);
return true;
}
catch (Exception)
{
return false;
}
}
return true;
HandleFailure(action);
return false;

View File

@ -175,7 +175,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
GetSupportedNfsVersionsAndSetUI(action.Result);
List<SR.SRInfo> SRs = SR.ParseSRListXML(action.Result);
var SRs = action.SRs ?? new List<SR.SRInfo>();
if (SRs.Count == 0)
{
// Disable box

View File

@ -225,8 +225,25 @@ namespace XenAdmin.Actions
deviceConfig["chappassword"] = chapPassword;
}
var probeResults = SR.probe_ext(Session, pool.master.opaque_ref,
deviceConfig, SR.SRTypes.gfs2.ToString(), new Dictionary<string, string>());
List<Probe_result> probeResults;
try
{
probeResults = SR.probe_ext(Session, pool.master.opaque_ref,
deviceConfig, SR.SRTypes.gfs2.ToString(), new Dictionary<string, string>());
}
catch (Failure f)
{
//this will probably not happen for this scan, but be defensive
if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == "ISCSILogin")
{
if (deviceConfig.ContainsKey("chapuser") && deviceConfig.ContainsKey("chappassword"))
throw new Exception(Messages.ACTION_ISCSI_IQN_SCANNING_GFS2);
throw new Failure("SR_BACKEND_FAILURE_68");
}
throw;
}
var results = new List<IScsiIqnInfo>();
var index = -1;

View File

@ -66,7 +66,7 @@ namespace XenAdmin.Actions
public ISCSIPopulateLunsAction(IXenConnection connection, string targetHost,
UInt16 targetPort, string targetIQN, string chapUsername, string chapPassword)
: base(connection, string.Format(Messages.ACTION_ISCSI_LUN_SCANNING, targetHost))
: base(connection, string.Format(Messages.ACTION_ISCSI_LUN_SCANNING, targetHost), true)
{
this.targetHost = targetHost;
this.targetPort = targetPort;
@ -212,8 +212,24 @@ namespace XenAdmin.Actions
deviceConfig["chappassword"] = chapPassword;
}
var probeResults = SR.probe_ext(Session, pool.master.opaque_ref,
deviceConfig, SR.SRTypes.gfs2.ToString().ToLowerInvariant(), new Dictionary<string, string>());
List<Probe_result> probeResults;
try
{
probeResults = SR.probe_ext(Session, pool.master.opaque_ref,
deviceConfig, SR.SRTypes.gfs2.ToString().ToLowerInvariant(), new Dictionary<string, string>());
}
catch (Failure f)
{
if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == "ISCSILogin")
{
if (deviceConfig.ContainsKey("chapuser") && deviceConfig.ContainsKey("chappassword"))
throw new Failure(Messages.ACTION_ISCSI_IQN_SCANNING_GFS2);
throw new Failure("SR_BACKEND_FAILURE_68");
}
throw;
}
var results = new List<ISCSIInfo>();
foreach (var probeResult in probeResults)

View File

@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using XenAdmin.Network;
using XenAPI;
@ -41,18 +40,17 @@ namespace XenAdmin.Actions
public class SrProbeAction : PureAsyncAction
{
private readonly Host host;
public readonly SR.SRTypes SrType;
private readonly Dictionary<String, String> dconf;
private readonly Dictionary<string, string> dconf;
private readonly Dictionary<string, string> smconf;
public List<Probe_result> ProbeExtResult;
private readonly Dictionary<String, String> smconf;
public SR.SRTypes SrType { get; }
public List<SR.SRInfo> SRs { get; private set; }
/// <summary>
/// Won't appear in the program history (SuppressHistory == true).
/// </summary>
public SrProbeAction(IXenConnection connection, Host host, SR.SRTypes srType,
Dictionary<String, String> dconf, Dictionary<String, String> smconf)
Dictionary<string, string> dconf, Dictionary<string, string> smconf = null)
: base(connection, string.Format(Messages.ACTION_SCANNING_SR_FROM, Helpers.GetName(connection)), null, true)
{
this.host = host;
@ -82,27 +80,43 @@ namespace XenAdmin.Actions
Description = string.Format(Messages.ACTION_SR_SCANNING, SR.getFriendlyTypeName(srType), target);
this.smconf = smconf;
}
public SrProbeAction(IXenConnection connection, Host host, SR.SRTypes srType, Dictionary<String, String> dconf)
: this(connection, host, srType, dconf, new Dictionary<string, string>())
{
this.smconf = smconf ?? new Dictionary<string, string>();
}
protected override void Run()
{
if (SrType != SR.SRTypes.gfs2)
{
RelatedTask = SR.async_probe(this.Session, host.opaque_ref,
RelatedTask = SR.async_probe(Session, host.opaque_ref,
dconf, SrType.ToString().ToLowerInvariant(), smconf);
PollToCompletion();
SRs = SR.ParseSRListXML(Result);
}
else
{
ProbeExtResult = SR.probe_ext(this.Session, host.opaque_ref,
dconf, SrType.ToString().ToLowerInvariant(), smconf);
try
{
var result = SR.probe_ext(this.Session, host.opaque_ref,
dconf, SrType.ToString().ToLowerInvariant(), smconf);
SRs = SR.ParseSRList(result);
}
catch (Failure f)
{
if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0].StartsWith("SR_BACKEND_FAILURE") &&
f.ErrorDescription[1] == "DeviceNotFoundException")
{
//Ignore: special treatment of case where gfs2 cannot see the same devices as lvmohba (CA-335356)
}
else if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == "ISCSILogin" &&
dconf.ContainsKey("chapuser") && dconf.ContainsKey("chappassword"))
{
//Ignore: special treatment of gfs2 chap authentication failure (CA-337280)
}
else
throw;
}
}
Description = Messages.ACTION_SR_SCAN_SUCCESSFUL;
}
}

View File

@ -1518,6 +1518,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Thinly provisioned (GFS2) SRs with CHAP authentication are not supported..
/// </summary>
public static string ACTION_ISCSI_IQN_SCANNING_GFS2 {
get {
return ResourceManager.GetString("ACTION_ISCSI_IQN_SCANNING_GFS2", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Scanning for LUNs on iSCSI filer {0}.
/// </summary>
@ -21281,7 +21290,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Invalid target host.
/// Looks up a localized string similar to Invalid target host..
/// </summary>
public static string INVALID_HOST {
get {

View File

@ -603,6 +603,9 @@
<data name="ACTION_ISCSI_IQN_SCANNING" xml:space="preserve">
<value>Scanning for IQNs on iSCSI filer {0}</value>
</data>
<data name="ACTION_ISCSI_IQN_SCANNING_GFS2" xml:space="preserve">
<value>Thinly provisioned (GFS2) SRs with CHAP authentication are not supported.</value>
</data>
<data name="ACTION_ISCSI_LUN_SCANNING" xml:space="preserve">
<value>Scanning for LUNs on iSCSI filer {0}</value>
</data>