Skip to content
Open
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
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var (
globalHostBalance string
globalTLSCert atomic.Pointer[[]byte]
globalKeyPassword string
globalExitCode int
)

const (
Expand Down Expand Up @@ -1075,6 +1076,7 @@ func sidekickMain(ctx *cli.Context) {
globalHostBalance = "least"
}
globalKeyPassword = ctx.GlobalString("key-password")
globalExitCode = ctx.GlobalInt("exit-code")

tlsMaxVersion := uint16(tls.VersionTLS13)
switch tlsMax := ctx.GlobalString("tls-max"); tlsMax {
Expand Down Expand Up @@ -1242,7 +1244,7 @@ func sidekickMain(ctx *cli.Context) {
})
default:
console.Infof("caught signal '%s'\n", signal)
os.Exit(1)
os.Exit(globalExitCode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not so keen to add new flags. I think all what you need to do is to run os.Exit(143) when we receive syscall.SIGTERM. Kubernetes will understand that and will not flag an error for the container

}
}
}
Expand Down Expand Up @@ -1381,6 +1383,11 @@ func main() {
Value: "1.3",
Hidden: true,
},
cli.IntFlag{
Name: "exit-code",
Usage: "exit code to use when program terminates by a signal",
Value: 1,
},
}
app.CustomAppHelpTemplate = `NAME:
{{.Name}} - {{.Description}}
Expand Down
Loading