Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Fix the signal reset on SIGs during Stop #58

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ func NewRunner(env *setup.Environment) *Runtime {
runTimestamp: time.Now(),
ApplyChan: make(chan struct{}),
}
signal.Notify(run.SigChan, syscall.SIGTERM, syscall.SIGINT)
run.api = api.NewAPI(run.SigChan, run.DeleteAPIManifests, run.state.IsReady, run.ApplyChan)
return run
}

func (r *Runtime) Run() error {
// the associated signal.Reset is defer in r.Stop method
signal.Notify(r.SigChan, syscall.SIGTERM, syscall.SIGINT)

defer close(r.ApplyChan)

glog.Infof("Timeout for this current run is %s", r.runTimeout.String())
Expand Down Expand Up @@ -100,7 +102,6 @@ func (r *Runtime) Run() error {
sigStopChan := make(chan os.Signal, 2)
defer close(sigStopChan)
signal.Notify(sigStopChan, syscall.SIGTSTP)
defer signal.Reset(syscall.SIGTERM, syscall.SIGINT)

kubeletProbeURL := fmt.Sprintf("http://127.0.0.1:%d/healthz", r.env.GetKubeletHealthzPort())
for {
Expand Down
5 changes: 4 additions & 1 deletion pkg/run/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ func (r *Runtime) runJournalTailers(failedUnits []string) error {
}

func (r *Runtime) Stop(withError error) error {
// reset run signals
signal.Reset(syscall.SIGTERM, syscall.SIGINT)

if r.env.IsSkippingStop() {
glog.Infof("Skipping stop")
return withError
Expand All @@ -226,7 +229,7 @@ func (r *Runtime) Stop(withError error) error {
failed, err := r.probeUnitStatuses()
if err != nil && len(failed) == 0 {
glog.Errorf("Probe units in failed: %v", err)
return err
errs = append(errs, err.Error())
}

if len(failed) != 0 {
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/systemd_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func StartUnit(d *dbus.Conn, unitName string) error {
expectedSubState: []string{"running"},
getUnitStates: MustGetUnitStates,
}
glog.V(2).Infof("Starting %s ...", unitName)
return sd.executeSystemdAction()
}

Expand All @@ -119,6 +120,7 @@ func StopUnit(d *dbus.Conn, unitName string) error {
expectedSubState: []string{"dead", "failed"},
getUnitStates: GetUnitStates,
}
glog.V(2).Infof("Stopping %s ...", unitName)
return sd.executeSystemdAction()
}

Expand Down