Skip to content

Commit 2562958

Browse files
authored
Merge pull request #88 from alibaba/tengine-ingress-3.1.0
Tengine ingress 3.1.0
2 parents 1e19e97 + f3844b7 commit 2562958

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

internal/ingress/controller/config/config.go

+5
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,10 @@ type Configuration struct {
762762
// Value Format: server_port: domain, server_port: domain[, server_port: domain]*
763763
// custom-port-domain: "443: xxx.com, 2443: yyy.com"
764764
CustomPortDomain map[string]string `json:"custom-port-domain"`
765+
766+
// Sleep time for layer 4 load balancer during stop process
767+
// Unit: seconds
768+
MaxSleepTimeForStop int `json:"max-stop-sleep-time-for-stop"`
765769
}
766770

767771
// NewDefault returns the default nginx configuration
@@ -939,6 +943,7 @@ func NewDefault() Configuration {
939943
MaxRespAddHeaderNum: 2,
940944
MaxRespAppendHeaderNum: 2,
941945
User: "root",
946+
MaxSleepTimeForStop: 35,
942947
}
943948

944949
if klog.V(5) {

internal/ingress/controller/nginx.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,13 @@ func (n *NGINXController) Stop() error {
436436
}
437437
}
438438

439+
cfg := n.store.GetBackendConfiguration()
440+
lock.RemoveFile(cfg.StatusTengineFilePath)
441+
klog.Infof("Sleeping %v seconds for traffic from layer 4 LB", cfg.MaxSleepTimeForStop)
442+
time.Sleep(time.Duration(cfg.MaxSleepTimeForStop) * time.Second)
443+
439444
// send stop signal to Tengine
440-
klog.Info("Stopping Tengine process")
445+
klog.Info("Stopping Tengine process gracefully")
441446
cmd := n.command.ExecCommand("-s", "quit")
442447
cmd.Stdout = os.Stdout
443448
cmd.Stderr = os.Stderr
@@ -450,7 +455,7 @@ func (n *NGINXController) Stop() error {
450455
timer := time.NewTicker(time.Second * 1)
451456
for range timer.C {
452457
if !nginx.IsRunning() {
453-
klog.Info("Tengine process has stopped")
458+
klog.Info("Tengine process has stopped gracefully")
454459
timer.Stop()
455460
break
456461
}

0 commit comments

Comments
 (0)