tasks: Monitor v2 tasks in initFunc as well

When containerd is restarted, only v1 tasks are monitored again. This
leads to the lack of existing v2 task metrics.

Signed-off-by: Li Yuxuan <liyuxuan04@baidu.com>
This commit is contained in:
Li Yuxuan 2020-08-19 20:32:31 +08:00
parent 6c74c391fd
commit 4422ae3638

View File

@ -118,6 +118,13 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
l.monitor.Monitor(t)
}
}
v2Tasks, err := l.v2Runtime.Tasks(ic.Context, true)
if err != nil {
return nil, err
}
for _, t := range v2Tasks {
l.monitor.Monitor(t)
}
return l, nil
}