Fix scheduler status handling#5978
Merged
Merged
Conversation
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
t-kikuc
commented
Jun 30, 2025
| handler.Cancel() | ||
| finalStatus := s.executeStage(sig, s.deployment.Stages[0]) | ||
| assert.Equal(t, model.StageStatus_STAGE_FAILURE, finalStatus) | ||
| assert.Equal(t, model.StageStatus_STAGE_CANCELLED, finalStatus) |
Member
Author
There was a problem hiding this comment.
due to this change:
if err := s.reportStageStatus(ctx, ps.Id, model.StageStatus_STAGE_RUNNING, ps.Requires); err != nil {
if sig.Signal() == StopSignalCancel {
return model.StageStatus_STAGE_CANCELLED
}
return model.StageStatus_STAGE_FAILURE
}
t-kikuc
commented
Jun 30, 2025
Comment on lines
+305
to
+313
| if ps.Status == model.StageStatus_STAGE_SKIPPED { | ||
| statusReason = fmt.Sprintf("Stage %s has been already skipped", ps.Id) | ||
| continue | ||
| } | ||
| if ps.Status == model.StageStatus_STAGE_EXITED { | ||
| deploymentStatus = model.DeploymentStatus_DEPLOYMENT_SUCCESS | ||
| statusReason = fmt.Sprintf("Deployment was exited before stage %s", ps.Id) | ||
| break | ||
| } |
Member
Author
There was a problem hiding this comment.
These are [2].
[1] is not related to here.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5978 +/- ##
==========================================
- Coverage 28.16% 28.16% -0.01%
==========================================
Files 516 516
Lines 55895 55904 +9
==========================================
+ Hits 15743 15745 +2
- Misses 38900 38906 +6
- Partials 1252 1253 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
t-kikuc
commented
Jun 30, 2025
Comment on lines
+542
to
+544
| if sig.Signal() == StopSignalCancel { | ||
| return model.StageStatus_STAGE_CANCELLED | ||
| } |
t-kikuc
commented
Jun 30, 2025
Comment on lines
+492
to
+498
| defer func() { | ||
| // Ensure reporting the status even if the stage is cancelled. | ||
| if err := s.reportStageStatus(context.Background(), ps.Id, finalStatus, ps.Requires); err != nil { | ||
| s.logger.Error("failed to report stage status", zap.Error(err)) | ||
| } | ||
| }() | ||
|
|
Member
Author
There was a problem hiding this comment.
The cause of [1]-A was that reportStageStatus was not called when the stage is cancelled and returns some status before reportStageStatus at the bottom of this method.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does:
[1] Use
deferto ensure reporting the status even if the stage is cancelled[2] Handle Skipped/Exited before
executeStagewhen the stage was already completed by a previous scheduler.Why we need it:
[1] Without this PR, the following problems will occur:
A. The stage is marked as 'running' forever. (it should be 'cancelled')
B. The stage is marked as 'failure' even if I cancelled. (it should be 'cancelled')
[2] To simplify status handling in executeStage.
Which issue(s) this PR fixes:
Part of #5259
Does this PR introduce a user-facing change?: