Skip to content

Commit 7c10442

Browse files
author
Alfredo Santamaria Gomez
committed
fixing microsoft/service-fabric-issues#1054 flatten inner exception (KeyVaultClient.GetSecretAsync) and fixing add Cert to linux vmss ClientStore bug
1 parent e9778c5 commit 7c10442

File tree

2 files changed

+34
-39
lines changed

2 files changed

+34
-39
lines changed

src/ResourceManager/ServiceFabric/Commands.ServiceFabric/Commands/ServiceFabricClusterCertificateCmdlet.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
415415
{
416416
var secretGroup = vmss.VirtualMachineProfile.OsProfile.Secrets.SingleOrDefault(
417417
s => s.SourceVault.Id.Equals(certInformation.KeyVault.Id, StringComparison.OrdinalIgnoreCase));
418+
419+
420+
string configStore = null;
421+
if (vmss.VirtualMachineProfile.OsProfile.WindowsConfiguration != null)
422+
{
423+
configStore = Constants.DefaultCertificateStore;
424+
}
425+
418426
if (secretGroup == null)
419427
{
420428
vmss.VirtualMachineProfile.OsProfile.Secrets.Add(
@@ -428,7 +436,7 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
428436
{
429437
new VaultCertificate()
430438
{
431-
CertificateStore = Constants.DefaultCertificateStore,
439+
CertificateStore = configStore,
432440
CertificateUrl = certInformation.SecretUrl
433441
}
434442
}
@@ -449,7 +457,7 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
449457
secretGroup.VaultCertificates.Add(
450458
new VaultCertificate()
451459
{
452-
CertificateStore = Constants.DefaultCertificateStore,
460+
CertificateStore = configStore,
453461
CertificateUrl = certInformation.SecretUrl
454462
});
455463
}
@@ -460,7 +468,7 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
460468
{
461469
new VaultCertificate()
462470
{
463-
CertificateStore = Constants.DefaultCertificateStore,
471+
CertificateStore = configStore,
464472
CertificateUrl = certInformation.SecretUrl
465473
}
466474
};
@@ -586,7 +594,16 @@ private string GetThumbprintFromSecret(string secretUrl)
586594
throw new PSArgumentException("secretUrl");
587595
}
588596

589-
var secretBundle = this.KeyVaultClient.GetSecretAsync(secretUrl).Result;
597+
SecretBundle secretBundle;
598+
try
599+
{
600+
secretBundle = this.KeyVaultClient.GetSecretAsync(secretUrl).Result;
601+
}
602+
catch (Exception ex)
603+
{
604+
throw GetInnerException(ex);
605+
}
606+
590607
var secretValue = secretBundle.Value;
591608
try
592609
{

src/ResourceManager/ServiceFabric/Commands.ServiceFabric/Commands/ServiceFabricClusterCmdlet.cs

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,7 @@ protected PSCluster SendPutRequest(Cluster clusterResource, bool runOnSameThread
9393
catch (Exception e)
9494
{
9595
PrintSdkExceptionDetail(e);
96-
97-
if (e.InnerException != null)
98-
{
99-
while (e.InnerException != null)
100-
{
101-
e = e.InnerException;
102-
}
103-
104-
throw;
105-
}
106-
107-
throw;
96+
throw GetInnerException(e);
10897
}
10998

11099
return new PSCluster(cluster);
@@ -163,18 +152,7 @@ protected PSCluster SendPatchRequest(ClusterUpdateParameters request, bool runOn
163152
catch (Exception e)
164153
{
165154
PrintSdkExceptionDetail(e);
166-
167-
if (e.InnerException != null)
168-
{
169-
while (e.InnerException != null)
170-
{
171-
e = e.InnerException;
172-
}
173-
174-
throw;
175-
}
176-
177-
throw;
155+
throw GetInnerException(e);
178156
}
179157

180158
return new PSCluster(cluster);
@@ -193,17 +171,7 @@ protected Cluster GetCurrentCluster()
193171
}
194172
catch (Exception e)
195173
{
196-
if (e.InnerException != null)
197-
{
198-
while (e.InnerException != null)
199-
{
200-
e = e.InnerException;
201-
}
202-
203-
throw;
204-
}
205-
206-
throw;
174+
throw GetInnerException(e);
207175
}
208176
}
209177

@@ -349,5 +317,15 @@ protected void WriteClusterAndVmssVerboseWhenUpdate(List<Task> allTasks, bool pr
349317
exceptions.ForEach(PrintSdkExceptionDetail);
350318
task.Wait();
351319
}
320+
321+
protected Exception GetInnerException(Exception exception)
322+
{
323+
while (exception.InnerException != null)
324+
{
325+
exception = exception.InnerException;
326+
}
327+
328+
return exception;
329+
}
352330
}
353331
}

0 commit comments

Comments
 (0)