Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 457b075

Browse files
committed
flush glog when reap pod and containerd
Signed-off-by: Crazykev <[email protected]>
1 parent ac10f4e commit 457b075

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

containerd/containerd.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const (
3232
defaultStateDir = "/run/runv-containerd"
3333
defaultListenType = "unix"
3434
defaultGRPCEndpoint = "/run/runv-containerd/containerd.sock"
35+
// runv-containerd is a relativly short term program
36+
// since we can't change the flush interval in glog, flush here manaully.
37+
glogFlushInterval = 5 * time.Second
3538
)
3639

3740
var ContainerdCommand = cli.Command{
@@ -152,6 +155,8 @@ func daemon(sv *supervisor.Supervisor, address string) error {
152155
s := make(chan os.Signal, 2048)
153156
signal.Notify(s, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
154157

158+
go glogFlushDaemon()
159+
155160
server, err := startServer(address, sv)
156161
if err != nil {
157162
return err
@@ -161,6 +166,7 @@ func daemon(sv *supervisor.Supervisor, address string) error {
161166
glog.V(1).Infof("stopping containerd after receiving %s", sig)
162167
time.Sleep(3 * time.Second) // TODO: fix it by proper way
163168
server.Stop()
169+
glog.Flush()
164170
return nil
165171
}
166172

@@ -200,3 +206,9 @@ func startServer(address string, sv *supervisor.Supervisor) (*grpc.Server, error
200206
}()
201207
return s, nil
202208
}
209+
210+
func glogFlushDaemon() {
211+
for range time.NewTicker(glogFlushInterval).C {
212+
glog.Flush()
213+
}
214+
}

supervisor/hyperpod.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,4 +529,5 @@ func (hp *HyperPod) reap() {
529529
if err := os.RemoveAll(filepath.Join(hypervisor.BaseDir, hp.vm.Id)); err != nil {
530530
glog.Errorf("can't remove vm dir %q: %v", filepath.Join(hypervisor.BaseDir, hp.vm.Id), err)
531531
}
532+
glog.Flush()
532533
}

0 commit comments

Comments
 (0)