Skip to content

Commit 0b18d36

Browse files
committed
cleanup: replace custom signal handling with Kubernetes apiserver.SetupSignalContext as they are identical.
Signed-off-by: s-z-z <[email protected]>
1 parent fc84a60 commit 0b18d36

File tree

3 files changed

+2
-74
lines changed

3 files changed

+2
-74
lines changed

pkg/manager/signals/signal.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,7 @@ limitations under the License.
1717
package signals
1818

1919
import (
20-
"context"
21-
"os"
22-
"os/signal"
20+
apiserver "k8s.io/apiserver/pkg/server"
2321
)
2422

25-
var onlyOneSignalHandler = make(chan struct{})
26-
27-
// SetupSignalHandler registers for SIGTERM and SIGINT. A context is returned
28-
// which is canceled on one of these signals. If a second signal is caught, the program
29-
// is terminated with exit code 1.
30-
func SetupSignalHandler() context.Context {
31-
close(onlyOneSignalHandler) // panics when called twice
32-
33-
ctx, cancel := context.WithCancel(context.Background())
34-
35-
c := make(chan os.Signal, 2)
36-
signal.Notify(c, shutdownSignals...)
37-
go func() {
38-
<-c
39-
cancel()
40-
<-c
41-
os.Exit(1) // second signal. Exit directly.
42-
}()
43-
44-
return ctx
45-
}
23+
var SetupSignalHandler = apiserver.SetupSignalContext

pkg/manager/signals/signal_posix.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

pkg/manager/signals/signal_windows.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)