-
Notifications
You must be signed in to change notification settings - Fork 7
Set user error if there are no eligble resource to fault in target zone. #18
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
Open
arpja
wants to merge
8
commits into
Azure:main
Choose a base branch
from
arpja:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15133fb
- Bug fix for AKS and App Service.
arpja bf89728
Merge branch 'Azure:main' into main
arpja abd3b99
- Addind new param SubscriptionToTargetZone
arpja 86d3322
Add SubscriptionToTargetZone JSON dict param; keep TargetZone for bac…
arpja 07967b9
Merge branch 'Azure:main' into main
arpja 069d2e6
Merge branch 'Azure:main' into main
arpja 137bb81
- update the code to update job status kas skipped since resources di…
arpja d146e5c
- updating the scripts to set an error code for resources where fault…
arpja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -500,9 +500,18 @@ if ($operationObjects.Count -eq 0 -and $unexpectedOutputs.Count -gt 0) { | |
|
|
||
| $scriptEnd = Get-Date | ||
| $successCount = ($operationObjects | Where-Object { $_.IsSuccess }).Count | ||
| $failureCount = ($operationObjects | Where-Object { -not $_.IsSuccess }).Count | ||
| $skippedCount = ($operationObjects | Where-Object { $_.Status -eq 'Skipped' }).Count | ||
| $failureCount = ($operationObjects | Where-Object { -not $_.IsSuccess -and $_.Status -ne 'Skipped' }).Count | ||
| $failureCount += $unexpectedOutputs.Count | ||
| $overallStatus = if ($failureCount -eq 0) { 'Success' } elseif ($successCount -gt 0) { 'PartialSuccess' } else { 'Failed' } | ||
| # A skipped resource (no eligible nodes to fault in the target zone) is surfaced as a dedicated | ||
| # user error (RHDSUserErrorAKSNoNodesToFaultInTargetZone) and downgrades the run to PartialSuccess. | ||
| $overallStatus = if ($failureCount -gt 0 -and $successCount -eq 0 -and $skippedCount -eq 0) { | ||
| 'Failed' | ||
| } elseif ($failureCount -gt 0 -or $skippedCount -gt 0) { | ||
| 'PartialSuccess' | ||
| } else { | ||
| 'Success' | ||
| } | ||
|
|
||
| $resourceResults = @() | ||
| foreach ($op in $operationObjects) { | ||
|
|
@@ -522,11 +531,16 @@ foreach ($op in $operationObjects) { | |
| } | ||
| $durationMs = [int]([Math]::Round((($endTime) - $startTime).TotalMilliseconds)) | ||
| $err = $null | ||
| if (-not $op.IsSuccess) { | ||
| $metadata = @{ Status = $op.Status } | ||
| if ($op.Status -eq 'Skipped') { | ||
| # No eligible nodes to fault in the target zone - report as a dedicated user error. | ||
| $err = @{ ErrorCode='RHDSUserErrorAKSNoNodesToFaultInTargetZone'; Message=$op.ErrorMessage; Details=$op.ErrorMessage; Category='Skipped'; IsRetryable=$false } | ||
| } | ||
| elseif (-not $op.IsSuccess) { | ||
| $err = @{ ErrorCode='FailedToFaultResource'; Message=$op.ErrorMessage; Details=$op.ErrorMessage; Category=$op.Status; IsRetryable=$false } | ||
| } | ||
| $processedAtUtc = $endTime.ToUniversalTime() | ||
| $resourceResults += @{ ResourceId=$op.ResourceId; IsSuccess=$op.IsSuccess; Error=$err; ProcessedAt=$processedAtUtc; ProcessingDurationMs=$durationMs; Metadata=@{ Status=$op.Status } } | ||
| $resourceResults += @{ ResourceId=$op.ResourceId; IsSuccess=$op.IsSuccess; Error=$err; ProcessedAt=$processedAtUtc; ProcessingDurationMs=$durationMs; Metadata=$metadata } | ||
| } | ||
|
|
||
| foreach ($unexpected in $unexpectedOutputs) { | ||
|
|
@@ -546,13 +560,18 @@ $executionResult = [ordered]@{ | |
| $executionJson = $executionResult | ConvertTo-Json -Depth 6 | ||
| Write-Output $executionJson | ||
|
|
||
| # Fail the runbook if any resource could not be faulted | ||
| # Fail the runbook only on genuine faults. Skipped resources (no eligible nodes to fault in the | ||
| # target zone) are reported as a dedicated user error with PartialSuccess and do not fail the run. | ||
| if ($failureCount -gt 0) { | ||
| $errorMsg = "Runbook failed: $failureCount out of $($AksTargetList.Count) AKS cluster(s) could not be faulted. Status: $overallStatus" | ||
| Write-Error $errorMsg -ErrorAction Stop | ||
| throw $errorMsg | ||
| } | ||
|
|
||
| Write-Verbose "All AKS zone fault operations completed successfully." | ||
| if ($skippedCount -gt 0) { | ||
| Write-Verbose "AKS zone fault completed with PartialSuccess. $skippedCount of $($AksTargetList.Count) cluster(s) had no eligible nodes to fault in the target zone (RHDSUserErrorAKSNoNodesToFaultInTargetZone)." | ||
| } else { | ||
| Write-Verbose "All AKS zone fault operations completed successfully." | ||
| } | ||
|
Member
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. How are we handling the this skipped return at the Drills code? |
||
|
|
||
| #endregion | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 hope the skipped status is returned by the $op. Please check or confirm once.