Skip to content

Commit

Permalink
Enhance error logging in event watcher with additional context for pu…
Browse files Browse the repository at this point in the history
…sh and commit failures

Signed-off-by: t-kikuc <[email protected]>
  • Loading branch information
t-kikuc committed Dec 23, 2024
1 parent cedc8f2 commit 7dd40c7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/app/piped/eventwatcher/eventwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func (w *watcher) execute(ctx context.Context, repo git.Repo, repoID string, eve
for branch, events := range branchHandledEvents {
_, err = retry.Do(ctx, func() (interface{}, error) {
if err := tmpRepo.Push(ctx, branch); err != nil {
w.logger.Error("failed to push commits", zap.Error(err))
w.logger.Error("failed to push commits", zap.String("repo-id", repoID), zap.String("branch", branch), zap.Error(err))
return nil, err
}
return nil, nil

Check warning on line 464 in pkg/app/piped/eventwatcher/eventwatcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/eventwatcher/eventwatcher.go#L460-L464

Added lines #L460 - L464 were not covered by tests
Expand Down Expand Up @@ -603,7 +603,7 @@ func (w *watcher) updateValues(ctx context.Context, repo git.Repo, repoID string
retry := backoff.NewRetry(retryPushNum, backoff.NewConstant(retryPushInterval))
_, err = retry.Do(ctx, func() (interface{}, error) {
if err := tmpRepo.Push(ctx, tmpRepo.GetClonedBranch()); err != nil {
w.logger.Error("failed to push commits", zap.Error(err))
w.logger.Error("failed to push commits", zap.String("repo-id", repoID), zap.String("branch", tmpRepo.GetClonedBranch()), zap.Error(err))
return nil, err
}
return nil, nil

Check warning on line 609 in pkg/app/piped/eventwatcher/eventwatcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/eventwatcher/eventwatcher.go#L605-L609

Added lines #L605 - L609 were not covered by tests
Expand Down Expand Up @@ -693,7 +693,11 @@ func (w *watcher) commitFiles(ctx context.Context, latestEvent *model.Event, eve
branch := makeBranchName(newBranch, eventName, repo.GetClonedBranch())
trailers := maps.Clone(latestEvent.Contexts)
if err := repo.CommitChanges(ctx, branch, commitMsg, newBranch, changes, trailers); err != nil {
w.logger.Error("failed to perform git commit", zap.Error(err))
w.logger.Error("failed to perform git commit",
zap.String("branch", branch),
zap.Bool("make-new-branch", newBranch),
zap.Int("changed-files", len(changes)),
zap.Error(err))
return "", err

Check warning on line 701 in pkg/app/piped/eventwatcher/eventwatcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/eventwatcher/eventwatcher.go#L696-L701

Added lines #L696 - L701 were not covered by tests
}
w.logger.Info(fmt.Sprintf("event watcher will update values of Event %q", eventName))
Expand Down

0 comments on commit 7dd40c7

Please sign in to comment.