Skip to content

Fix bug adding certificate to linux vmss, flatten exception and fix service fabric durability upgrade issue #7597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
- Additional information about change #1
-->
## Current Release
* Fix add certificate to Linux Vmss.

* Fix `Add-AzureRmServiceFabricClusterCertificate`
- Using correct thumbprint from new certificate (Azure/service-fabric-issues#932).
- Display exception correctly (Azure/service-fabric-issues#1054).

* Fix `Update-AzureRmServiceFabricDurability` to update cluster configuration before starting Vmss CreateOrUpdate operation.

## Version 0.3.12
* Fixed issue with default resource groups not being set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,14 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
{
var secretGroup = vmss.VirtualMachineProfile.OsProfile.Secrets.SingleOrDefault(
s => s.SourceVault.Id.Equals(certInformation.KeyVault.Id, StringComparison.OrdinalIgnoreCase));


string configStore = null;
if (vmss.VirtualMachineProfile.OsProfile.WindowsConfiguration != null)
{
configStore = Constants.DefaultCertificateStore;
}

if (secretGroup == null)
{
vmss.VirtualMachineProfile.OsProfile.Secrets.Add(
Expand All @@ -428,7 +436,7 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
{
new VaultCertificate()
{
CertificateStore = Constants.DefaultCertificateStore,
CertificateStore = configStore,
CertificateUrl = certInformation.SecretUrl
}
}
Expand All @@ -449,7 +457,7 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
secretGroup.VaultCertificates.Add(
new VaultCertificate()
{
CertificateStore = Constants.DefaultCertificateStore,
CertificateStore = configStore,
CertificateUrl = certInformation.SecretUrl
});
}
Expand All @@ -460,7 +468,7 @@ internal Task AddCertToVmssTask(VirtualMachineScaleSet vmss, CertificateInformat
{
new VaultCertificate()
{
CertificateStore = Constants.DefaultCertificateStore,
CertificateStore = configStore,
CertificateUrl = certInformation.SecretUrl
}
};
Expand Down Expand Up @@ -586,7 +594,16 @@ private string GetThumbprintFromSecret(string secretUrl)
throw new PSArgumentException("secretUrl");
}

var secretBundle = this.KeyVaultClient.GetSecretAsync(secretUrl).Result;
SecretBundle secretBundle;
try
{
secretBundle = this.KeyVaultClient.GetSecretAsync(secretUrl).Result;
}
catch (Exception ex)
{
throw GetInnerException(ex);
}

var secretValue = secretBundle.Value;
try
{
Expand Down Expand Up @@ -615,7 +632,11 @@ private string GetThumbprintFromSecret(string secretUrl)
jsonBlob.Password,
X509KeyStorageFlags.Exportable);

return certCollection[0].Thumbprint;
var lastCert = certCollection.Count > 0 ? certCollection[certCollection.Count - 1] : null;
if (lastCert?.Thumbprint != null)
{
return lastCert.Thumbprint;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,7 @@ protected PSCluster SendPutRequest(Cluster clusterResource, bool runOnSameThread
catch (Exception e)
{
PrintSdkExceptionDetail(e);

if (e.InnerException != null)
{
while (e.InnerException != null)
{
e = e.InnerException;
}

throw;
}

throw;
throw GetInnerException(e);
}

return new PSCluster(cluster);
Expand Down Expand Up @@ -163,18 +152,7 @@ protected PSCluster SendPatchRequest(ClusterUpdateParameters request, bool runOn
catch (Exception e)
{
PrintSdkExceptionDetail(e);

if (e.InnerException != null)
{
while (e.InnerException != null)
{
e = e.InnerException;
}

throw;
}

throw;
throw GetInnerException(e);
}

return new PSCluster(cluster);
Expand All @@ -193,17 +171,7 @@ protected Cluster GetCurrentCluster()
}
catch (Exception e)
{
if (e.InnerException != null)
{
while (e.InnerException != null)
{
e = e.InnerException;
}

throw;
}

throw;
throw GetInnerException(e);
}
}

Expand Down Expand Up @@ -349,5 +317,15 @@ protected void WriteClusterAndVmssVerboseWhenUpdate(List<Task> allTasks, bool pr
exceptions.ForEach(PrintSdkExceptionDetail);
task.Wait();
}

protected Exception GetInnerException(Exception exception)
{
while (exception.InnerException != null)
{
exception = exception.InnerException;
}

return exception;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@ public override void ExecuteCmdlet()
NodeTypes = cluster.NodeTypes
};

var patchTask = PatchAsync(patchArg);
var psCluster = SendPatchRequest(patchArg);

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

var psCluster = new PSCluster(patchTask.Result);
WriteObject(psCluster, true);
}
}
Expand Down