Skip to content
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

Merged
merged 18 commits into from
Mar 10, 2017
Merged

Added option to SkipUpgradeSameTypeAndVersion #3529

merged 18 commits into from
Mar 10, 2017

Conversation

mikanyg
Copy link
Contributor

@mikanyg mikanyg commented Feb 2, 2017

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

@msftclas
Copy link

msftclas commented Feb 2, 2017

Hi @mikanyg, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

@mikanyg
Copy link
Contributor Author

mikanyg commented Feb 9, 2017

@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

@ericsciple
Copy link
Contributor

@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*') {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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
}
}
Copy link
Member

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

Copy link
Contributor Author

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.

@@ -130,7 +131,8 @@ try {
{
$publishParameters['Action'] = "RegisterAndUpgrade"
$publishParameters['UpgradeParameters'] = $upgradeParameters
$publishParameters['UnregisterUnusedVersions'] = $true
$publishParameters['UnregisterUnusedVersions'] = $true
Copy link
Member

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

@NCarlsonMSFT
Copy link
Member

VS Code tips: you can turn on viewing white space with the setting:
"editor.renderWhitespace": "all"

and you can make VS Code auto-remove trailing white space with the settings:
"files.trimTrailingWhitespace": true

@mikanyg
Copy link
Contributor Author

mikanyg commented Feb 10, 2017

Moved my VS Code comment to the review. Still a bit new to the PR and review experience in github

@NCarlsonMSFT
Copy link
Member

NCarlsonMSFT commented Feb 10, 2017

Don't worry, I'm still learning Git Hub PRs too.

"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."
Copy link
Member

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.

Copy link
Contributor Author

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.

@NCarlsonMSFT
Copy link
Member

@ericsciple does anyone else need to sign-off before merging?

@mikanyg
Copy link
Contributor Author

mikanyg commented Mar 6, 2017

@NCarlsonMSFT is this PR considered dead, or is it just busy time at MS?

@NCarlsonMSFT
Copy link
Member

@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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants