Skip to content

Commit

Permalink
Merge pull request #811 from degica/inc-startup-timeout
Browse files Browse the repository at this point in the history
increase the startup timeout for the run pack
  • Loading branch information
davidsiaw authored May 10, 2024
2 parents e20d438 + d25e005 commit 3882436
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-run-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: workaround
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
Expand Down
16 changes: 16 additions & 0 deletions dockerfiles/run-pack/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module degica.com/run-pack

go 1.21.6

require (
github.com/aws/aws-sdk-go v1.4.6
github.com/mitchellh/go-ps v0.0.0-20160822165447-e2d21980687c
github.com/urfave/cli v1.18.1
)

require (
github.com/go-ini/ini v1.21.1 // indirect
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
github.com/stretchr/testify v1.9.0 // indirect
)
26 changes: 26 additions & 0 deletions dockerfiles/run-pack/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
github.com/aws/aws-sdk-go v1.4.6 h1:ZD4LyFcHq1Mz729ZAalUPoPTQMXN/oM3MjpH7/Lqcaw=
github.com/aws/aws-sdk-go v1.4.6/go.mod h1:ZRmQr0FajVIyZ4ZzBYKG5P3ZqPz9IHG41ZoMu1ADI3k=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ini/ini v1.21.1 h1:+QXUYsI7Tfxc64oD6R5BxU/Aq+UwGkyjH4W/hMNG7bg=
github.com/go-ini/ini v1.21.1/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7 h1:SMvOWPJCES2GdFracYbBQh93GXac8fq7HeN6JnpduB8=
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/mitchellh/go-ps v0.0.0-20160822165447-e2d21980687c h1:PGjV7YcIjgi6Fax/envGM6klZAxa4NUu53jSBV1dS+w=
github.com/mitchellh/go-ps v0.0.0-20160822165447-e2d21980687c/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli v1.18.1 h1:IFc93MpteseEF1dvLEwx5Zn+K7xkbIcBGp36OwYlFx8=
github.com/urfave/cli v1.18.1/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
15 changes: 10 additions & 5 deletions dockerfiles/run-pack/watch_interactive_session.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package main

import (
"fmt"
"log"
"os"
"time"

ps "github.com/mitchellh/go-ps"
)

const StartupTimeoutSeconds = 3 * 60
const RunTimeoutHours = 24
const TickIntervalSeconds = 5

func otherSessionRunning(processes []ps.Process) (ps.Process, error) {
for _, p := range processes {
// pid == 1: the process was spawned by `docker run` command
Expand All @@ -27,9 +32,9 @@ func otherSessionRunning(processes []ps.Process) (ps.Process, error) {
func watchInteractiveSession() {
log.Println("Interactive run watcher started")

startTimeout := time.After(30 * time.Second)
runTimeout := time.After(24 * time.Hour)
tick := time.Tick(5 * time.Second)
startTimeout := time.After(StartupTimeoutSeconds * time.Second)
runTimeout := time.After(RunTimeoutHours * time.Hour)
tick := time.Tick(TickIntervalSeconds * time.Second)
sessionStarted := false
for {
select {
Expand All @@ -54,11 +59,11 @@ func watchInteractiveSession() {
}
case <-startTimeout:
if !sessionStarted {
log.Println("Interactive session has not started for 30 seconds")
log.Println(fmt.Sprintf("Interactive session has not started for %d seconds", StartupTimeoutSeconds))
os.Exit(2)
}
case <-runTimeout:
log.Println("Interactive session has run for over 24 hours")
log.Println(fmt.Sprintf("Interactive session has run for over %d hours", RunTimeoutHours))
os.Exit(2)
}
}
Expand Down

0 comments on commit 3882436

Please sign in to comment.