-
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 telemetries #7474
Added telemetries #7474
Changes from 2 commits
ca15d09
babe265
cf4e039
0293dd7
eb952bf
1464774
cc213f3
b6c316b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,11 @@ | |
|
||
[Parameter(ParameterSetName = "ApplicationParameterFilePath")] | ||
[Parameter(ParameterSetName = "ApplicationName")] | ||
[Switch]$CompressPackage | ||
[Switch]$CompressPackage, | ||
|
||
[Parameter(ParameterSetName = "ApplicationParameterFilePath")] | ||
[Parameter(ParameterSetName = "ApplicationName")] | ||
[ref]$status | ||
) | ||
|
||
|
||
|
@@ -142,6 +146,7 @@ | |
|
||
if (!$SkipPackageValidation) | ||
{ | ||
$status.value = "NewApp-TestingApplicationPackage" | ||
$packageValidationSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove redundant Test-. Keep it only in deploy.ps1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will raise a separate PR for the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please file an issue for that - otherwise we will miss it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if (!$packageValidationSuccess) | ||
{ | ||
|
@@ -217,6 +222,7 @@ | |
|
||
try | ||
{ | ||
$status.value = "NewApp-RemovingApplication" | ||
$app | Remove-ServiceFabricApplication -Force | ||
} | ||
catch [System.TimeoutException] | ||
|
@@ -230,6 +236,7 @@ | |
# It will unregister the existing application's type and version even if its different from the application being created, | ||
if ((Get-ServiceFabricApplication | Where-Object {$_.ApplicationTypeVersion -eq $($app.ApplicationTypeVersion) -and $_.ApplicationTypeName -eq $($app.ApplicationTypeName)}).Count -eq 0) | ||
{ | ||
$status.value = "NewApp-UnregisteringApplicationType" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than settings similar status multiple places, you can move it to separate method and call it from both New/upgrade file. I don't think adding "NewApp-" or "UpgradeApp-" prefix is necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding these prefixes will give us clear idea about the code flow without any need to look in other trace to decide whether code is in Create flow or Upgrade flow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to know whether it is upgrade or new when lets say registering the package? This information seems to be redundant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing it in the hope that we don't need to know whether code failed in CreateApp or UpgradeApp. |
||
Unregister-ServiceFabricApplicationType -ApplicationTypeName $($app.ApplicationTypeName) -ApplicationTypeVersion $($app.ApplicationTypeVersion) -Force -TimeoutSec $UnregisterPackageTimeoutSec | ||
} | ||
} | ||
|
@@ -250,13 +257,14 @@ | |
} | ||
if (!$typeIsInUse) | ||
{ | ||
$status.value = "NewApp-UnregisteringRegisteredApplicationType" | ||
Write-Host (Get-VstsLocString -Key SFSDK_UnregisteringExistingAppType -ArgumentList @($names.ApplicationTypeName, $names.ApplicationTypeVersion)) | ||
$reg | Unregister-ServiceFabricApplicationType -Force -TimeoutSec $UnregisterPackageTimeoutSec | ||
$ApplicationTypeAlreadyRegistered = $false | ||
if (!$?) | ||
{ | ||
throw (Get-VstsLocString -Key SFSDK_UnableToUnregisterAppType) | ||
} | ||
$ApplicationTypeAlreadyRegistered = $false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its a bug since !$? check for last command ran successfully or not and $ApplicationTypeAlreadyRegistered = $false is not the one for which we're checking for |
||
} | ||
else | ||
{ | ||
|
@@ -302,7 +310,7 @@ | |
Write-Warning (Get-VstsLocString -Key SFSDK_CompressPackageWarning $InstalledSdkVersion) | ||
} | ||
} | ||
|
||
$status.value = "NewApp-CopyingApplicationPackage" | ||
Copy-ServiceFabricApplicationPackage @copyParameters | ||
if (!$?) | ||
{ | ||
|
@@ -319,12 +327,13 @@ | |
} | ||
|
||
Write-Host (Get-VstsLocString -Key SFSDK_RegisterAppType) | ||
$status.value = "NewApp-RegisteringApplicationType" | ||
Register-ServiceFabricApplicationType @registerParameters | ||
if (!$?) | ||
{ | ||
throw (Get-VstsLocString -Key SFSDK_RegisterAppTypeFailed) | ||
} | ||
|
||
$status.value = "NewApp-RemovingApplicationPackage" | ||
Write-Host (Get-VstsLocString -Key SFSDK_RemoveAppPackage) | ||
Remove-ServiceFabricApplicationPackage -ApplicationPackagePathInImageStore $applicationPackagePathInImageStore -ImageStoreConnectionString $imageStoreConnectionString | ||
} | ||
|
@@ -347,7 +356,7 @@ | |
$ApplicationParameter = Merge-Hashtables -HashTableOld $appParamsFromFile -HashTableNew $ApplicationParameter | ||
} | ||
} | ||
|
||
$status.value = "NewApp-CreatingNewApplication" | ||
New-ServiceFabricApplication -ApplicationName $ApplicationName -ApplicationTypeName $names.ApplicationTypeName -ApplicationTypeVersion $names.ApplicationTypeVersion -ApplicationParameter $ApplicationParameter | ||
if (!$?) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ try { | |
} | ||
} | ||
|
||
$status = "ConnectingToCluster" | ||
# Connect to cluster | ||
Connect-ServiceFabricClusterFromServiceEndpoint -ClusterConnectionParameters $clusterConnectionParameters -ConnectedServiceEndpoint $connectedServiceEndpoint | ||
|
||
|
@@ -107,6 +108,7 @@ try { | |
|
||
if (!$skipValidation) | ||
{ | ||
$status = "TestingApplicationPackage" | ||
$isPackageValid = Test-ServiceFabricApplicationPackage -ApplicationPackagePath $applicationPackagePath | ||
} | ||
|
||
|
@@ -176,16 +178,22 @@ try { | |
$publishParameters['UpgradeParameters'] = $upgradeParameters | ||
$publishParameters['UnregisterUnusedVersions'] = $unregisterUnusedVersions | ||
$publishParameters['SkipUpgradeSameTypeAndVersion'] = $skipUpgrade | ||
$publishParameters['Status'] = [ref]$status | ||
|
||
Publish-UpgradedServiceFabricApplication @publishParameters | ||
} | ||
else | ||
{ | ||
$publishParameters['Action'] = "RegisterAndCreate" | ||
$publishParameters['OverwriteBehavior'] = Get-VstsInput -Name overwriteBehavior | ||
$publishParameters['Status'] = [ref]$status | ||
|
||
Publish-NewServiceFabricApplication @publishParameters | ||
} | ||
} finally { | ||
} | ||
catch { | ||
Write-Telemetry "Task_InternalError" "TaskStatus: $status | Exception: $_.Exception.GetType().FullName" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove words "TaskStatus:" and "Exception:". We can use convention to have status and exception type separated by | without any space. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used it for readability. If you don't see any use then lets remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is redundant. As we will never need to see full string. We will always query this data via kusto and it is easier to write query without these extra characters |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you need to re-throw? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we need to re throw |
||
finally { | ||
Trace-VstsLeavingInvocation $MyInvocation | ||
} |
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.
$status is good candidate global variable - then you won't need to pass along.
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.
Lets us PassByReference as its more controlled and always safer then to use Global variable
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.
Passing an extra optional parameter (with reference) still seems fine to me as there is no extra memory usage
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.
In this case there does not seem to be usual problems related to global variables. Before execution a command will set status and that will always be the truth - we don't have multi-threading or parallelization in our flow.
I am in favor of global as code will be cleaner without need to pass $status everywhere.
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.
Using global variable now.