Skip to content

Commit 04b17b6

Browse files
authored
Merge pull request #7597 from a-santamaria/preview
Fix bug adding certificate to linux vmss, flatten exception and fix service fabric durability upgrade issue
2 parents e04ca2e + a968fc4 commit 04b17b6

File tree

4 files changed

+48
-43
lines changed

4 files changed

+48
-43
lines changed

src/ResourceManager/ServiceFabric/Commands.ServiceFabric/ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Fix add certificate to Linux Vmss.
22+
23+
* Fix `Add-AzureRmServiceFabricClusterCertificate`
24+
- Using correct thumbprint from new certificate (Azure/service-fabric-issues#932).
25+
- Display exception correctly (Azure/service-fabric-issues#1054).
26+
27+
* Fix `Update-AzureRmServiceFabricDurability` to update cluster configuration before starting Vmss CreateOrUpdate operation.
2128

2229
## Version 0.3.12
2330
* Fixed issue with default resource groups not being set.

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

Lines changed: 26 additions & 5 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
{
@@ -615,7 +632,11 @@ private string GetThumbprintFromSecret(string secretUrl)
615632
jsonBlob.Password,
616633
X509KeyStorageFlags.Exportable);
617634

618-
return certCollection[0].Thumbprint;
635+
var lastCert = certCollection.Count > 0 ? certCollection[certCollection.Count - 1] : null;
636+
if (lastCert?.Thumbprint != null)
637+
{
638+
return lastCert.Thumbprint;
639+
}
619640
}
620641
}
621642
}

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
}

src/ResourceManager/ServiceFabric/Commands.ServiceFabric/Commands/UpdateAzureRmServiceFabricDurability.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,10 @@ public override void ExecuteCmdlet()
125125
NodeTypes = cluster.NodeTypes
126126
};
127127

128-
var patchTask = PatchAsync(patchArg);
128+
var psCluster = SendPatchRequest(patchArg);
129129

130-
WriteClusterAndVmssVerboseWhenUpdate(new List<Task>() { vmssTask, patchTask }, true, this.NodeType);
130+
WriteClusterAndVmssVerboseWhenUpdate(new List<Task>() { vmssTask }, false, this.NodeType);
131131

132-
var psCluster = new PSCluster(patchTask.Result);
133132
WriteObject(psCluster, true);
134133
}
135134
}

0 commit comments

Comments
 (0)