Skip to content

Commit

Permalink
Moving up the logic for skip upgrade (#7373)
Browse files Browse the repository at this point in the history
* Moving up the logic to skip upgrade

* Moving up the logic to check the existence of old application

* Modified code as per review comments
  • Loading branch information
vinodkumar3 committed Jun 6, 2018
1 parent a1b9ff5 commit eff31b7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,45 @@ function Publish-UpgradedServiceFabricApplication
throw $errMsg
}

$ApplicationManifestPath = "$AppPkgPathToUse\ApplicationManifest.xml"

$names = Get-NamesFromApplicationManifest -ApplicationManifestPath $ApplicationManifestPath
if (!$names)
{
return
}

# If ApplicationName is not specified on command line get application name from Application parameter file.
if (!$ApplicationName)
{
$ApplicationName = Get-ApplicationNameFromApplicationParameterFile $ApplicationParameterFilePath
}

if (!$ApplicationName)
{
Write-Error (Get-VstsLocString -Key EmptyApplicationName)
}

$oldApplication = Get-ServiceFabricApplication -ApplicationName $ApplicationName
## Check existence of the application
if (!$oldApplication)
{
$errMsg = (Get-VstsLocString -Key SFSDK_AppDoesNotExist -ArgumentList $ApplicationName)
throw $errMsg
}

if ($oldApplication.ApplicationTypeName -ne $names.ApplicationTypeName)
{
$errMsg = (Get-VstsLocString -Key SFSDK_AppTypeMismatch -ArgumentList $ApplicationName)
throw $errMsg
}

if ($SkipUpgradeSameTypeAndVersion -And $oldApplication.ApplicationTypeVersion -eq $names.ApplicationTypeVersion)
{
Write-Warning (Get-VstsLocString -Key SFSDK_SkipUpgradeWarning -ArgumentList @($names.ApplicationTypeName, $names.ApplicationTypeVersion))
return
}

# Get image store connection string
$clusterManifestText = Get-ServiceFabricClusterManifest
$imageStoreConnectionString = Get-ImageStoreConnectionStringFromClusterManifest ([xml] $clusterManifestText)
Expand All @@ -160,8 +199,6 @@ function Publish-UpgradedServiceFabricApplication
}
}

$ApplicationManifestPath = "$AppPkgPathToUse\ApplicationManifest.xml"

try
{
[void](Test-ServiceFabricClusterConnection)
Expand All @@ -172,49 +209,9 @@ function Publish-UpgradedServiceFabricApplication
throw
}

# If ApplicationName is not specified on command line get application name from Application parameter file.
if (!$ApplicationName)
{
$ApplicationName = Get-ApplicationNameFromApplicationParameterFile $ApplicationParameterFilePath
}

if (!$ApplicationName)
{
Write-Error (Get-VstsLocString -Key EmptyApplicationName)
}

$names = Get-NamesFromApplicationManifest -ApplicationManifestPath $ApplicationManifestPath
if (!$names)
{
return
}

$ApplicationTypeAlreadyRegistered = $false
if ($Action.Equals('RegisterAndUpgrade') -or $Action.Equals('Register'))
{
## Check existence of the application
$oldApplication = Get-ServiceFabricApplication -ApplicationName $ApplicationName

if (!$oldApplication)
{
$errMsg = (Get-VstsLocString -Key SFSDK_AppDoesNotExist -ArgumentList $ApplicationName)
throw $errMsg
}
else
{
if ($oldApplication.ApplicationTypeName -ne $names.ApplicationTypeName)
{
$errMsg = (Get-VstsLocString -Key SFSDK_AppTypeMismatch -ArgumentList $ApplicationName)
throw $errMsg
}

if ($SkipUpgradeSameTypeAndVersion -And $oldApplication.ApplicationTypeVersion -eq $names.ApplicationTypeVersion)
{
Write-Warning (Get-VstsLocString -Key SFSDK_SkipUpgradeWarning -ArgumentList @($names.ApplicationTypeName, $names.ApplicationTypeVersion))
return
}
}

## Check upgrade status
$upgradeStatus = Get-ServiceFabricApplicationUpgrade -ApplicationName $ApplicationName
if ($upgradeStatus.UpgradeState -ne "RollingBackCompleted" -and $upgradeStatus.UpgradeState -ne "RollingForwardCompleted")
Expand Down
2 changes: 1 addition & 1 deletion Tasks/ServiceFabricDeploy/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 7,
"Patch": 10
"Patch": 11
},
"demands": [
"Cmd"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/ServiceFabricDeploy/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 7,
"Patch": 10
"Patch": 11
},
"demands": [
"Cmd"
Expand Down

0 comments on commit eff31b7

Please sign in to comment.