Skip to content

Commit

Permalink
log when directory clearing fails (#1782)
Browse files Browse the repository at this point in the history
* log when directory clearing fails
  • Loading branch information
motatoes authored Oct 29, 2024
1 parent 19dff18 commit cbdc36e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 12 additions & 2 deletions backend/controllers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,13 @@ func handlePushEvent(gh utils.GithubClientProvider, payload *github.PushEvent) e
}

func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullRequestEvent, ciBackendProvider ci_backends.CiBackendProvider) error {
appId, err := strconv.ParseInt(os.Getenv("GITHUB_APP_ID"), 10, 64)
if err != nil {
log.Printf("error getting github app isntallation id: %v", err)
return fmt.Errorf("error getting github app installation id")
}

installationId := *payload.Installation.ID
appId := *payload.Installation.AppID
repoName := *payload.Repo.Name
repoOwner := *payload.Repo.Owner.Login
repoFullName := *payload.Repo.FullName
Expand Down Expand Up @@ -697,8 +702,13 @@ func getBatchType(jobs []orchestrator_scheduler.Job) orchestrator_scheduler.Digg
}

func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.IssueCommentEvent, ciBackendProvider ci_backends.CiBackendProvider) error {
appId, err := strconv.ParseInt(os.Getenv("GITHUB_APP_ID"), 10, 64)
if err != nil {
log.Printf("error getting github app isntallation id: %v", err)
return fmt.Errorf("error getting github app installation id")
}

installationId := *payload.Installation.ID
appId := *payload.Installation.AppID
repoName := *payload.Repo.Name
repoOwner := *payload.Repo.Owner.Login
repoFullName := *payload.Repo.FullName
Expand Down
8 changes: 7 additions & 1 deletion backend/utils/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ func CloneGitRepoAndDoAction(repoUrl string, branch string, token string, action
log.Printf("PlainClone error: %v\n", err)
return err
}
defer os.RemoveAll(dir)
defer func() {
log.Printf("removing cloned directory %v", dir)
ferr := os.RemoveAll(dir)
if ferr != nil {
log.Printf("WARN: removal of dir %v failed: %v", dir, ferr)
}
}()

err = action(dir)
if err != nil {
Expand Down

0 comments on commit cbdc36e

Please sign in to comment.