Skip to content

Commit cbdc36e

Browse files
authored
log when directory clearing fails (#1782)
* log when directory clearing fails
1 parent 19dff18 commit cbdc36e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

backend/controllers/github.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,13 @@ func handlePushEvent(gh utils.GithubClientProvider, payload *github.PushEvent) e
388388
}
389389

390390
func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullRequestEvent, ciBackendProvider ci_backends.CiBackendProvider) error {
391+
appId, err := strconv.ParseInt(os.Getenv("GITHUB_APP_ID"), 10, 64)
392+
if err != nil {
393+
log.Printf("error getting github app isntallation id: %v", err)
394+
return fmt.Errorf("error getting github app installation id")
395+
}
396+
391397
installationId := *payload.Installation.ID
392-
appId := *payload.Installation.AppID
393398
repoName := *payload.Repo.Name
394399
repoOwner := *payload.Repo.Owner.Login
395400
repoFullName := *payload.Repo.FullName
@@ -697,8 +702,13 @@ func getBatchType(jobs []orchestrator_scheduler.Job) orchestrator_scheduler.Digg
697702
}
698703

699704
func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.IssueCommentEvent, ciBackendProvider ci_backends.CiBackendProvider) error {
705+
appId, err := strconv.ParseInt(os.Getenv("GITHUB_APP_ID"), 10, 64)
706+
if err != nil {
707+
log.Printf("error getting github app isntallation id: %v", err)
708+
return fmt.Errorf("error getting github app installation id")
709+
}
710+
700711
installationId := *payload.Installation.ID
701-
appId := *payload.Installation.AppID
702712
repoName := *payload.Repo.Name
703713
repoOwner := *payload.Repo.Owner.Login
704714
repoFullName := *payload.Repo.FullName

backend/utils/github.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ func CloneGitRepoAndDoAction(repoUrl string, branch string, token string, action
5252
log.Printf("PlainClone error: %v\n", err)
5353
return err
5454
}
55-
defer os.RemoveAll(dir)
55+
defer func() {
56+
log.Printf("removing cloned directory %v", dir)
57+
ferr := os.RemoveAll(dir)
58+
if ferr != nil {
59+
log.Printf("WARN: removal of dir %v failed: %v", dir, ferr)
60+
}
61+
}()
5662

5763
err = action(dir)
5864
if err != nil {

0 commit comments

Comments
 (0)