-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Added option to SkipUpgradeSameTypeAndVersion #3529
Conversation
…NewServiceFabricApplication cmdlet. Placed in new Advanced group and defaults to SameAppTypeAndVersion to keep backwards compatability.
- Incremented task patch number - removed trailing whitespace - moved test constants to variable
- taking latest Patch
…nd skip the entire upgrade, making the upgrade process idempotent.
… skipUpgrade logic
Hi @mikanyg, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
@mikkelhegn @ericsciple Would you consider this PR in regards to #3346 or do you have other plans for ServiceFabricDeploy task based on the comment by @mikkelhegn |
@NCarlsonMSFT to consider |
} | ||
catch [System.Fabric.FabricException] { | ||
## If SkipUpgrade param is set when existing version already deployed, then back out of upgrade | ||
if($SkipUpgradeSameTypeAndVersion -And $Error[0].Exception.Message -like '*Application type and version is still in use*') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking based on the error message won't work on a non-english machine and will break if the Service Fabric platform changes their error messages. Have you looked at the Error Code property? It looks like the value ApplicationAlreadyInTargetVersion may be what you are looking for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, missed the ErrorCode property before.
Regarding the enum value it would ideally be ApplicationAlreadyInTargetVersion thrown during upgrade, but the exception occurs prior to the upgrade, instead it is ApplicationTypeInUse thrown when the app type and version is already found and is being unregistered.
I never truly understood why an app would be unregistered before an upgrade, but thought is was some sort of pre-validation step, which would cause the error to be thrown, hopefully intentionaly. I don't know if the pre-validation step is really needed if the upgrade actally throws ApplicationAlreadyInTargetVersion if it finds the same app type and version as in the upgrade package. Then the catch block could just wrap the upgrade step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just talked with an Engineer on the Platform. His recommendation is to call Get-ServiceFabricApplication -ApplicationName and check the ApplicationTypeVersion property on that to decide whether or not to skip deployment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will look into that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NCarlsonMSFT Changed the logic from being exception handling to pre-validation using the existing code that checked for existing of app in the cluster. Was actually much simpler than the first implementation.
But seems like my new VS Code settings removed a lot trailing whitespace from the file. Should I revert and re-apply my changed to keep PR to only new features or do you prefer the removal of trailing whitespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not worried about removing the extra white-space (I'm personally glad it's gone, always been a pet peeve of mine)
The new logic does look cleaner and I think the change looks good. I need to manually test it before signing off though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do take it for a spin, remember its on redeployments that the skip upgrade part kicks in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functionality looks good, I added one more comment in task.json based on the UI experience.
else { | ||
throw | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block has a bunch of stray whitespace on the end of the lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really don't know why the trailing spaces appear. I am just using VS Code on Win10 with default settings. The diff tool does not show them untill I actually remove them after a commit.
Tasks/ServiceFabricDeploy/deploy.ps1
Outdated
@@ -130,7 +131,8 @@ try { | |||
{ | |||
$publishParameters['Action'] = "RegisterAndUpgrade" | |||
$publishParameters['UpgradeParameters'] = $upgradeParameters | |||
$publishParameters['UnregisterUnusedVersions'] = $true | |||
$publishParameters['UnregisterUnusedVersions'] = $true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only change to this line is stray whitespace, please remove
VS Code tips: you can turn on viewing white space with the setting: and you can make VS Code auto-remove trailing white space with the settings: |
Moved my VS Code comment to the review. Still a bit new to the PR and review experience in github |
Don't worry, I'm still learning Git Hub PRs too. |
Tasks/ServiceFabricDeploy/task.json
Outdated
"defaultValue": "false", | ||
"required": false, | ||
"groupname": "upgrade", | ||
"helpMarkDown": "Indicates whether an upgrade will be skipped if the same application type and version already exists in the cluster, otherwise the upgrade fails during validation. If enabled, re-deployments are idempotent." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once I deployed this I noticed the UI around this check-box gets a bit funky with the behavior of the "Override All Publish Profile Upgrade Settings" check-box. could you please move this to the advanced group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I placed it in the upgrade group since it was related to upgrades, but yes it looks and behaves a bit odd, when selecting/deselecting the override publish settings and upgrade checkbox.
@ericsciple does anyone else need to sign-off before merging? |
@NCarlsonMSFT is this PR considered dead, or is it just busy time at MS? |
@mikanyg sorry, it's not dead but it has been a busy time. I'm still trying to verify if any other sign-off is needed before merging. |
|
||
[Parameter(ParameterSetName="ApplicationParameterFilePath")] | ||
[Parameter(ParameterSetName="ApplicationName")] | ||
[Switch]$SkipUpgradeSameTypeAndVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include this parameter's description in function doc above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
This PR gives the option to make upgrades idempotent by skipping the upgrade if the following error 'Continue on 'Application type and version is still in use' occurs during upgrade validation. Solves #3346