From 9442b52b9a1ade40857d16c65dca7993703bc5d9 Mon Sep 17 00:00:00 2001 From: mustard Date: Mon, 28 Oct 2024 17:53:54 +0800 Subject: [PATCH] [supervisor] switch lib back to use upstream `ramr/go-reaper` (#20322) --- components/supervisor/cmd/init.go | 18 +++++++++++------- components/supervisor/go.mod | 1 + components/supervisor/go.sum | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/components/supervisor/cmd/init.go b/components/supervisor/cmd/init.go index 0a120bf995c47b..ff7e36447aa288 100644 --- a/components/supervisor/cmd/init.go +++ b/components/supervisor/cmd/init.go @@ -22,8 +22,8 @@ import ( "github.com/gitpod-io/gitpod/common-go/process" "github.com/gitpod-io/gitpod/supervisor/pkg/shared" "github.com/gitpod-io/gitpod/supervisor/pkg/supervisor" - reaper "github.com/gitpod-io/go-reaper" "github.com/prometheus/procfs" + reaper "github.com/ramr/go-reaper" "github.com/spf13/cobra" ) @@ -114,18 +114,22 @@ var initCmd = &cobra.Command{ } }() // start the reaper to clean up zombie processes + reaperChan := make(chan reaper.Status, 10) reaper.Start(reaper.Config{ Pid: -1, Options: 0, DisablePid1Check: false, - OnReap: func(pid int, wstatus syscall.WaitStatus) { - if pid != runCommand.Process.Pid { - return + StatusChannel: reaperChan, + }) + go func() { + for status := range reaperChan { + if status.Pid != runCommand.Process.Pid { + continue } - exitCode := wstatus.ExitStatus() + exitCode := status.WaitStatus.ExitStatus() handledByReaper <- exitCode - }, - }) + } + }() select { case <-supervisorDone: diff --git a/components/supervisor/go.mod b/components/supervisor/go.mod index 87d7fa7c40fc38..6fa95e1454ee8a 100644 --- a/components/supervisor/go.mod +++ b/components/supervisor/go.mod @@ -30,6 +30,7 @@ require ( github.com/prometheus/common v0.42.0 github.com/prometheus/procfs v0.10.1 github.com/prometheus/pushgateway v1.5.1 + github.com/ramr/go-reaper v0.2.2 github.com/sirupsen/logrus v1.9.3 github.com/soheilhy/cmux v0.1.5 github.com/spf13/cobra v1.4.0 diff --git a/components/supervisor/go.sum b/components/supervisor/go.sum index 3f5fee0ea5bdbb..2500a31a467a38 100644 --- a/components/supervisor/go.sum +++ b/components/supervisor/go.sum @@ -119,8 +119,6 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM= github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= -github.com/gitpod-io/go-reaper v0.0.0-20241023132555-bf7fe3193e95 h1:8CExGQuXMl8ZgFzkBfU1+K8+yFLxqttXz9JGPBaoY0g= -github.com/gitpod-io/go-reaper v0.0.0-20241023132555-bf7fe3193e95/go.mod h1:WJlnZLfag2J4+z28ZjM0CxgVqjYVYF8pnspnleDwrcA= github.com/gitpod-io/go-reaper v0.0.0-20241024192051-78d04cc2e25f h1:jC8c/ONG+vsaxY6y17rM+Du7JN/faYfSBiMCFIi2NoA= github.com/gitpod-io/go-reaper v0.0.0-20241024192051-78d04cc2e25f/go.mod h1:WJlnZLfag2J4+z28ZjM0CxgVqjYVYF8pnspnleDwrcA= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -323,6 +321,8 @@ github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+Pymzi github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/prometheus/pushgateway v1.5.1 h1:F+meNVGklhdkJTrpt5l3pXLc86m6IG3+ZF3VfeOwubE= github.com/prometheus/pushgateway v1.5.1/go.mod h1:BcYcT8no4mdtnZxqpkXH3EMT0/Jf2nKgSlwu6GHirU4= +github.com/ramr/go-reaper v0.2.2 h1:oQrw3LPL+TiEVb57+UZUHzW7k98N7Rv67TRuCRufLog= +github.com/ramr/go-reaper v0.2.2/go.mod h1:AVypdzrcCXjSc/JYnlXl8TsB+z84WyFzxWE8Jh0MOJc= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=