acme solver wait for server to shutdown

Signed-off-by: Inteon <42113979+inteon@users.noreply.github.com>
This commit is contained in:
Inteon 2021-07-22 20:38:59 +02:00
parent 769e057663
commit f11c44dd15
No known key found for this signature in database
GPG Key ID: BD5DCF7303C7C1A7

View File

@ -18,6 +18,7 @@ package app
import (
"context"
"time"
"github.com/spf13/cobra"
@ -37,9 +38,15 @@ func NewACMESolverCommand(stopCh <-chan struct{}) *cobra.Command {
rootCtx = logf.NewContext(rootCtx, nil, "acmesolver")
log := logf.FromContext(rootCtx)
completedCh := make(chan struct{})
go func() {
defer close(completedCh)
<-stopCh
if err := s.Shutdown(rootCtx); err != nil {
// allow a timeout for graceful shutdown
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := s.Shutdown(ctx); err != nil {
log.Error(err, "error shutting down acmesolver server")
}
}()
@ -48,6 +55,8 @@ func NewACMESolverCommand(stopCh <-chan struct{}) *cobra.Command {
return err
}
<-completedCh
return nil
},
}