Skip to content
Closed
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 pkg/router/template/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os/exec"
"path/filepath"
"reflect"
"regexp"
"sort"
"strings"
"sync"
Expand All @@ -29,6 +30,7 @@ import (
)

var log = logf.Logger.WithName("template")
var noChildProcessesRegExp = regexp.MustCompile("[wait|waitid]: no child processes")

const (
ProtocolHTTP = "http"
Expand Down Expand Up @@ -542,7 +544,12 @@ func (r *templateRouter) writeCertificates(cfg *ServiceAliasConfig) error {
func (r *templateRouter) reloadRouter() error {
cmd := exec.Command(r.reloadScriptPath)
out, err := cmd.CombinedOutput()
if err != nil {
// Explicitly handle the case where the process has exited
// cleanly before we hit the call to wait() in
// CombinedOutput(). The logic there calls Start(), then
// Wait() and that could be racy if there is a GC pause (or
// other scheduling activity).
if err != nil && !noChildProcessesRegExp.MatchString(err.Error()) {
return fmt.Errorf("error reloading router: %v\n%s", err, string(out))
}
log.V(0).Info("router reloaded", "output", string(out))
Expand Down