Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion actionsdotnetactcompat/action_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"os"
"path"
"path/filepath"
"runtime/debug"
"strings"

"github.com/actions-oss/act-cli/pkg/common"
Expand All @@ -35,7 +37,14 @@ func (cache *ActionCacheBase) GetTarArchive(ctx context.Context, cacheDir, sha,
pr, pw := io.Pipe()
cleanIncludePrefix := path.Clean(includePrefix)
go func() {
defer func() { _ = pw.Close() }()
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
_ = pw.CloseWithError(fmt.Errorf("panic recovered in GetTarArchive: %v", r))
return
}
_ = pw.Close()
}()
writer := tar.NewWriter(pw)
defer func() { _ = writer.Close() }()
reader, err := os.Open(cache.mapping[cacheDir+"@"+sha])
Expand Down
21 changes: 21 additions & 0 deletions actionsrunner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -152,6 +153,11 @@ func (run *RunRunner) Run(runnerenv RunnerEnvironment, listenerctx, corectx cont
for _, instance := range settings.Instances {
//nolint:gosec
go func(instance *runnerconfiguration.RunnerInstance) (exitcode int) {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
defer wg.Done()
defer func() {
// Without this the inner return 1 got lost and we would retry it
Expand Down Expand Up @@ -189,6 +195,11 @@ func (run *RunRunner) Run(runnerenv RunnerEnvironment, listenerctx, corectx cont
Result: result,
}
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
for i := 0; ; i++ {
if err := vssConnection.FinishJob(finish, jobrun.Plan); err != nil {
runnerenv.Printf("Failed to finish previous stuck job with Status Failed: %v\n", err.Error())
Expand Down Expand Up @@ -450,6 +461,11 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro
session *protocol.AgentMessageConnection, message protocol.TaskAgentMessage, instance *runnerconfiguration.RunnerInstance,
) {
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
plogger := &PrefixConsoleLogger{
Parent: runnerenv,
Prefix: fmt.Sprintf("%v ( %v ):", instance.Agent.Name, instance.RegistrationURL),
Expand Down Expand Up @@ -539,6 +555,11 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro
}
con := *vssConnection
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
for {
renewErr := renewJob(jobctx, runServiceURL, jobreq, &con, instance)
if renewErr != nil {
Expand Down
24 changes: 22 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"os/signal"
"runtime"
"runtime/debug"
"strings"
"syscall"

Expand Down Expand Up @@ -120,6 +122,11 @@ func (run *RunRunner) Run() int {
listenerctx, cancelListener := context.WithCancel(context.Background())
defer cancelListener()
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
sig := <-channel
if sig == syscall.SIGTERM {
fmt.Println("SIGTERM received, cancel any current job and wait for completion")
Expand Down Expand Up @@ -215,15 +222,18 @@ func (svc *RunRunnerSvc) Start(s service.Service) error {
runner.Terminal = terminal
}

//nolint:gosec
ctx, cancel := context.WithCancel(context.Background())
//nolint:gosec
listenerctx, cancelListener := context.WithCancel(context.Background())
svc.stop = func() {
cancelListener()
}
svc.wait = make(chan error)
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
defer cancelListener()
defer cancel()
defer close(svc.wait)
Expand Down Expand Up @@ -404,6 +414,11 @@ func main() {
ccontext, cancelccontext := context.WithCancel(context.Background())
defer cancelccontext()
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
execcontext, cancelExec := context.WithCancel(context.Background())
defer cancelExec()
buf := make([]byte, bufferSize)
Expand Down Expand Up @@ -431,6 +446,11 @@ func main() {
fmt.Printf("unmarshal job request: %v", err)
}
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic recovered: %v\n%s", r, debug.Stack())
}
}()
defer cancelExec()
defer cancelccontext()
wc := &actionsrunner.DefaultWorkerContext{
Expand Down
Loading
Loading