-
Notifications
You must be signed in to change notification settings - Fork 6
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
[ORCA-4531] Improve pre workflow hook error handling #228
Changes from 9 commits
a74702a
2a72796
8a05a3c
c3c1b79
47dc75c
3cd4004
09714de
bd63649
268b563
e43085c
d522a3a
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
package events | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strconv" | ||
"time" | ||
|
@@ -129,8 +130,10 @@ type DefaultCommandRunner struct { | |
CommentCommandRunnerByCmd map[command.Name]command.Runner | ||
Drainer *Drainer | ||
PreWorkflowHooksCommandRunner PreWorkflowHooksCommandRunner | ||
CommitStatusUpdater CommitStatusUpdater | ||
PullStatusFetcher PullStatusFetcher | ||
StaleCommandChecker StaleCommandChecker | ||
Logger logging.Logger | ||
} | ||
|
||
// RunAutoplanCommand runs plan and policy_checks when a pull request is opened or updated. | ||
|
@@ -158,6 +161,7 @@ func (c *DefaultCommandRunner) RunAutoplanCommand(logger logging.SimpleLogging, | |
ctx := &command.Context{ | ||
User: user, | ||
Log: log, | ||
CtxLog: c.Logger, | ||
Scope: scope, | ||
Pull: pull, | ||
HeadRepo: headRepo, | ||
|
@@ -176,10 +180,12 @@ func (c *DefaultCommandRunner) RunAutoplanCommand(logger logging.SimpleLogging, | |
return | ||
} | ||
|
||
err = c.PreWorkflowHooksCommandRunner.RunPreHooks(ctx) | ||
|
||
if err != nil { | ||
ctx.Log.Errorf("Error running pre-workflow hooks %s. Proceeding with %s command.", err, command.Plan) | ||
if err := c.PreWorkflowHooksCommandRunner.RunPreHooks(context.TODO(), ctx); err != nil { | ||
c.Logger.ErrorContext(context.TODO(), "Error running pre-workflow hooks", map[string]interface{}{ | ||
"err": err, | ||
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. can you add repository and pull num here? similar to here: Eventually this can be added to ctx and ripped out from there automatically but for now we need this. 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. yeah, my thinking was that it will be covered by the context, but you're right in the meantime we need a workaround. |
||
}) | ||
c.CommitStatusUpdater.UpdateCombined(context.TODO(), ctx.HeadRepo, ctx.Pull, models.FailedCommitStatus, command.Plan) | ||
return | ||
} | ||
|
||
autoPlanRunner := buildCommentCommandRunner(c, command.Plan) | ||
|
@@ -226,6 +232,7 @@ func (c *DefaultCommandRunner) RunCommentCommand(logger logging.SimpleLogging, b | |
ctx := &command.Context{ | ||
User: user, | ||
Log: log, | ||
CtxLog: c.Logger, | ||
Pull: pull, | ||
PullStatus: status, | ||
HeadRepo: headRepo, | ||
|
@@ -243,10 +250,13 @@ func (c *DefaultCommandRunner) RunCommentCommand(logger logging.SimpleLogging, b | |
return | ||
} | ||
|
||
err = c.PreWorkflowHooksCommandRunner.RunPreHooks(ctx) | ||
if err := c.PreWorkflowHooksCommandRunner.RunPreHooks(context.TODO(), ctx); err != nil { | ||
c.Logger.ErrorContext(context.TODO(), "Error running pre-workflow hooks", map[string]interface{}{ | ||
"err": err, | ||
}) | ||
|
||
if err != nil { | ||
ctx.Log.Errorf("Error running pre-workflow hooks %s. Proceeding with %s command.", err, cmd.Name.String()) | ||
c.CommitStatusUpdater.UpdateCombined(context.TODO(), ctx.HeadRepo, ctx.Pull, models.FailedCommitStatus, cmd.Name) | ||
return | ||
} | ||
|
||
cmdRunner := buildCommentCommandRunner(c, cmd.CommandName()) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
can you remove this? Why have both? We're gonna need to do this for the whole codebase at some point anyways, might as well do it per file as we come across it.