From 7539d905e50861057640afabc2415a5b97f99c87 Mon Sep 17 00:00:00 2001 From: Bishal Prasad Date: Wed, 20 Jun 2018 16:00:18 +0530 Subject: [PATCH 1/4] Port from releases/m136: Fix SF deploy task (#7522) --- .../ServiceFabricDeployV1/ServiceFabricSDK/Utilities.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Utilities.ps1 b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Utilities.ps1 index 1f82f52d94b5..e5b2180d1ba7 100644 --- a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Utilities.ps1 +++ b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Utilities.ps1 @@ -213,7 +213,7 @@ function Get-ServiceFabricApplicationAction [string] $ApplicationTypeName, - [HashTable] + [string] $ApplicationName ) @@ -229,7 +229,7 @@ function Get-ServiceFabricApplicationAction } $global:operationId = $SF_Operations.GetApplication - return Get-ServiceFabricApplication $getApplicationParams + return Get-ServiceFabricApplication @getApplicationParams } function Get-ServiceFabricApplicationTypeAction @@ -240,7 +240,7 @@ function Get-ServiceFabricApplicationTypeAction ) $global:operationId = $SF_Operations.GetApplicationType - return Get-ServiceFabricApplication -ApplicationTypeName $ApplicationTypeName + return Get-ServiceFabricApplicationType -ApplicationTypeName $ApplicationTypeName } function Get-ServiceFabricApplicationUpgradeAction @@ -251,5 +251,5 @@ function Get-ServiceFabricApplicationUpgradeAction ) $global:operationId = $SF_Operations.GetApplicationUpgradeStatus - return Get-ServiceFabricApplication -ApplicationName $ApplicationName + return Get-ServiceFabricApplicationUpgrade -ApplicationName $ApplicationName } \ No newline at end of file From b90cbd11018f630d22d20f3d7113583d6bb2b1bd Mon Sep 17 00:00:00 2001 From: Bishal Prasad Date: Wed, 20 Jun 2018 17:25:56 +0530 Subject: [PATCH 2/4] test application package only if necessary --- .../Publish-NewServiceFabricApplication.ps1 | 22 +++++++------ ...blish-UpgradedServiceFabricApplication.ps1 | 33 ++++++++++--------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-NewServiceFabricApplication.ps1 b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-NewServiceFabricApplication.ps1 index 4be7d0a17159..019ba6ac9ba0 100644 --- a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-NewServiceFabricApplication.ps1 +++ b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-NewServiceFabricApplication.ps1 @@ -140,16 +140,7 @@ throw $errMsg } - if (!$SkipPackageValidation) - { - $global:operationId = $SF_Operations.TestApplicationPackage - $packageValidationSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse) - if (!$packageValidationSuccess) - { - $errMsg = (Get-VstsLocString -Key SFSDK_PackageValidationFailed -ArgumentList $ApplicationPackagePath) - throw $errMsg - } - } + $ApplicationManifestPath = "$AppPkgPathToUse\ApplicationManifest.xml" @@ -271,6 +262,17 @@ } if (!$reg -or !$ApplicationTypeAlreadyRegistered) { + if (!$SkipPackageValidation) + { + $global:operationId = $SF_Operations.TestApplicationPackage + $packageValidationSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse) + if (!$packageValidationSuccess) + { + $errMsg = (Get-VstsLocString -Key SFSDK_PackageValidationFailed -ArgumentList $ApplicationPackagePath) + throw $errMsg + } + } + Write-Host (Get-VstsLocString -Key SFSDK_CopyingAppToImageStore) # Get image store connection string $global:operationId = $SF_Operations.GetClusterManifest diff --git a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 index a020cc9c72cd..0c250e8a2c68 100644 --- a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 +++ b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 @@ -185,21 +185,6 @@ function Publish-UpgradedServiceFabricApplication return } - # Get image store connection string - $global:operationId = $SF_Operations.GetClusterManifest - $clusterManifestText = Get-ServiceFabricClusterManifest - $imageStoreConnectionString = Get-ImageStoreConnectionStringFromClusterManifest ([xml] $clusterManifestText) - - if (!$SkipPackageValidation) - { - $global:operationId = $SF_Operations.TestApplicationPackage - $packageValidationSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse -ImageStoreConnectionString $imageStoreConnectionString) - if (!$packageValidationSuccess) - { - $errMsg = (Get-VstsLocString -Key SFSDK_PackageValidationFailed -ArgumentList $ApplicationPackagePath) - throw $errMsg - } - } try { @@ -250,6 +235,22 @@ function Publish-UpgradedServiceFabricApplication if (!$reg -or !$ApplicationTypeAlreadyRegistered) { + # Get image store connection string + $global:operationId = $SF_Operations.GetClusterManifest + $clusterManifestText = Get-ServiceFabricClusterManifest + $imageStoreConnectionString = Get-ImageStoreConnectionStringFromClusterManifest ([xml] $clusterManifestText) + + if (!$SkipPackageValidation) + { + $global:operationId = $SF_Operations.TestApplicationPackage + $packageValidationSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse -ImageStoreConnectionString $imageStoreConnectionString) + if (!$packageValidationSuccess) + { + $errMsg = (Get-VstsLocString -Key SFSDK_PackageValidationFailed -ArgumentList $ApplicationPackagePath) + throw $errMsg + } + } + $applicationPackagePathInImageStore = $names.ApplicationTypeName Write-Host (Get-VstsLocString -Key SFSDK_CopyingAppToImageStore) @@ -383,7 +384,7 @@ function Publish-UpgradedServiceFabricApplication if ($UnregisterUnusedVersions) { Write-Host (Get-VstsLocString -Key SFSDK_UnregisterUnusedVersions) - foreach ($registeredAppTypes in Get-ServiceFabricApplicationTypeAction -ApplicationTypeName $names.ApplicationTypeName | Where-Object { $_.ApplicationTypeVersion -ne $names.ApplicationTypeVersion }) + foreach ($registeredAppTypes in Get-ServiceFabricApplicationTypeAction -ApplicationTypeName $names.ApplicationTypeName) { try { From bd14d5afaa4d64ef45b11c25411c2d15d39a0c66 Mon Sep 17 00:00:00 2001 From: Bishal Prasad Date: Thu, 21 Jun 2018 17:38:17 +0530 Subject: [PATCH 3/4] PR comments --- .../Publish-UpgradedServiceFabricApplication.ps1 | 8 ++++---- .../Strings/resources.resjson/en-US/resources.resjson | 3 ++- Tasks/ServiceFabricDeployV1/task.json | 3 ++- Tasks/ServiceFabricDeployV1/task.loc.json | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 index 0c250e8a2c68..e408debd5c09 100644 --- a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 +++ b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 @@ -384,16 +384,16 @@ function Publish-UpgradedServiceFabricApplication if ($UnregisterUnusedVersions) { Write-Host (Get-VstsLocString -Key SFSDK_UnregisterUnusedVersions) - foreach ($registeredAppTypes in Get-ServiceFabricApplicationTypeAction -ApplicationTypeName $names.ApplicationTypeName) + foreach ($registeredAppType in Get-ServiceFabricApplicationTypeAction -ApplicationTypeName $names.ApplicationTypeName) { try { $global:operationId = $SF_Operations.UnregisterApplicationType - $registeredAppTypes | Unregister-ServiceFabricApplicationType -Force -TimeoutSec $UnregisterPackageTimeoutSec + $registeredAppType | Unregister-ServiceFabricApplicationType -Force -TimeoutSec $UnregisterPackageTimeoutSec } - catch [System.Fabric.FabricException] + catch { - # AppType and Version in use. + Write-Warning (Get-VstsLocString -Key SFSDK_UnregisterAppTypeFailure -ArgumentList @($names.ApplicationTypeName, $registeredAppType.ApplicationTypeVersion, $_.Exception.ToString())) } } } diff --git a/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson b/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson index a703beb6477d..3b12e71f3dbf 100644 --- a/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson @@ -120,5 +120,6 @@ "loc.messages.SFSDK_CompressPackageWarning": "The CompressPackage parameter requires version '2.5' of the Service Fabric SDK, but the installed version is '{0}'. This parameter will be ignored.", "loc.messages.SFSDK_SkipUpgradeWarning": "Skipping upgrade, since application type '{0}' with version '{1}' already exists in cluster.", "loc.messages.SFSDK_UnregisterAppTypeFailed": "Failed to unregister application type. Error: {0}.", - "loc.messages.SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application." + "loc.messages.SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application.", + "loc.messages.SFSDK_UnregisterAppTypeFailure": "Failed to unregister application type '{0}' and version '{1}'. Error: {2}." } \ No newline at end of file diff --git a/Tasks/ServiceFabricDeployV1/task.json b/Tasks/ServiceFabricDeployV1/task.json index a21671c836f7..a82c3574a662 100644 --- a/Tasks/ServiceFabricDeployV1/task.json +++ b/Tasks/ServiceFabricDeployV1/task.json @@ -461,6 +461,7 @@ "SFSDK_CompressPackageWarning": "The CompressPackage parameter requires version '2.5' of the Service Fabric SDK, but the installed version is '{0}'. This parameter will be ignored.", "SFSDK_SkipUpgradeWarning": "Skipping upgrade, since application type '{0}' with version '{1}' already exists in cluster.", "SFSDK_UnregisterAppTypeFailed": "Failed to unregister application type. Error: {0}.", - "SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application." + "SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application.", + "SFSDK_UnregisterAppTypeFailure": "Failed to unregister application type '{0}' and version '{1}'. Error: {2}." } } \ No newline at end of file diff --git a/Tasks/ServiceFabricDeployV1/task.loc.json b/Tasks/ServiceFabricDeployV1/task.loc.json index eee944d463bf..6273c6a25da1 100644 --- a/Tasks/ServiceFabricDeployV1/task.loc.json +++ b/Tasks/ServiceFabricDeployV1/task.loc.json @@ -461,6 +461,7 @@ "SFSDK_CompressPackageWarning": "ms-resource:loc.messages.SFSDK_CompressPackageWarning", "SFSDK_SkipUpgradeWarning": "ms-resource:loc.messages.SFSDK_SkipUpgradeWarning", "SFSDK_UnregisterAppTypeFailed": "ms-resource:loc.messages.SFSDK_UnregisterAppTypeFailed", - "SFSDK_PerformingForceRemoveOnTimeout": "ms-resource:loc.messages.SFSDK_PerformingForceRemoveOnTimeout" + "SFSDK_PerformingForceRemoveOnTimeout": "ms-resource:loc.messages.SFSDK_PerformingForceRemoveOnTimeout", + "SFSDK_UnregisterAppTypeFailure": "ms-resource:loc.messages.SFSDK_UnregisterAppTypeFailure" } } \ No newline at end of file From 72f151247accf966916110a599839083d02d2876 Mon Sep 17 00:00:00 2001 From: Bishal Prasad Date: Thu, 21 Jun 2018 17:53:51 +0530 Subject: [PATCH 4/4] remove warning log --- .../Publish-UpgradedServiceFabricApplication.ps1 | 2 +- .../Strings/resources.resjson/en-US/resources.resjson | 3 +-- Tasks/ServiceFabricDeployV1/task.json | 3 +-- Tasks/ServiceFabricDeployV1/task.loc.json | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 index e408debd5c09..463ded1e18e5 100644 --- a/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 +++ b/Tasks/ServiceFabricDeployV1/ServiceFabricSDK/Publish-UpgradedServiceFabricApplication.ps1 @@ -393,7 +393,7 @@ function Publish-UpgradedServiceFabricApplication } catch { - Write-Warning (Get-VstsLocString -Key SFSDK_UnregisterAppTypeFailure -ArgumentList @($names.ApplicationTypeName, $registeredAppType.ApplicationTypeVersion, $_.Exception.ToString())) + # AppType and Version in use. } } } diff --git a/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson b/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson index 3b12e71f3dbf..a703beb6477d 100644 --- a/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/ServiceFabricDeployV1/Strings/resources.resjson/en-US/resources.resjson @@ -120,6 +120,5 @@ "loc.messages.SFSDK_CompressPackageWarning": "The CompressPackage parameter requires version '2.5' of the Service Fabric SDK, but the installed version is '{0}'. This parameter will be ignored.", "loc.messages.SFSDK_SkipUpgradeWarning": "Skipping upgrade, since application type '{0}' with version '{1}' already exists in cluster.", "loc.messages.SFSDK_UnregisterAppTypeFailed": "Failed to unregister application type. Error: {0}.", - "loc.messages.SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application.", - "loc.messages.SFSDK_UnregisterAppTypeFailure": "Failed to unregister application type '{0}' and version '{1}'. Error: {2}." + "loc.messages.SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application." } \ No newline at end of file diff --git a/Tasks/ServiceFabricDeployV1/task.json b/Tasks/ServiceFabricDeployV1/task.json index a82c3574a662..a21671c836f7 100644 --- a/Tasks/ServiceFabricDeployV1/task.json +++ b/Tasks/ServiceFabricDeployV1/task.json @@ -461,7 +461,6 @@ "SFSDK_CompressPackageWarning": "The CompressPackage parameter requires version '2.5' of the Service Fabric SDK, but the installed version is '{0}'. This parameter will be ignored.", "SFSDK_SkipUpgradeWarning": "Skipping upgrade, since application type '{0}' with version '{1}' already exists in cluster.", "SFSDK_UnregisterAppTypeFailed": "Failed to unregister application type. Error: {0}.", - "SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application.", - "SFSDK_UnregisterAppTypeFailure": "Failed to unregister application type '{0}' and version '{1}'. Error: {2}." + "SFSDK_PerformingForceRemoveOnTimeout": "Removal of application '{0}' is timing out, this means that the service is stuck in ChangeRole/Close and the shutdown sequence cannot complete. Performing ForceRemove of the application." } } \ No newline at end of file diff --git a/Tasks/ServiceFabricDeployV1/task.loc.json b/Tasks/ServiceFabricDeployV1/task.loc.json index 6273c6a25da1..eee944d463bf 100644 --- a/Tasks/ServiceFabricDeployV1/task.loc.json +++ b/Tasks/ServiceFabricDeployV1/task.loc.json @@ -461,7 +461,6 @@ "SFSDK_CompressPackageWarning": "ms-resource:loc.messages.SFSDK_CompressPackageWarning", "SFSDK_SkipUpgradeWarning": "ms-resource:loc.messages.SFSDK_SkipUpgradeWarning", "SFSDK_UnregisterAppTypeFailed": "ms-resource:loc.messages.SFSDK_UnregisterAppTypeFailed", - "SFSDK_PerformingForceRemoveOnTimeout": "ms-resource:loc.messages.SFSDK_PerformingForceRemoveOnTimeout", - "SFSDK_UnregisterAppTypeFailure": "ms-resource:loc.messages.SFSDK_UnregisterAppTypeFailure" + "SFSDK_PerformingForceRemoveOnTimeout": "ms-resource:loc.messages.SFSDK_PerformingForceRemoveOnTimeout" } } \ No newline at end of file