1 Star 0 Fork 1

Derek Ray/podman

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
runtime_migrate.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
Matthew Heon 提交于 2019-05-01 15:07 . Small fixes for #2950
package libpod
import (
"context"
"path/filepath"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
func (r *Runtime) migrate(ctx context.Context) error {
runningContainers, err := r.GetRunningContainers()
if err != nil {
return err
}
allCtrs, err := r.state.AllContainers()
if err != nil {
return err
}
logrus.Infof("stopping all containers")
for _, ctr := range runningContainers {
logrus.Infof("stopping %s", ctr.ID())
if err := ctr.Stop(); err != nil {
return errors.Wrapf(err, "cannot stop container %s", ctr.ID())
}
}
for _, ctr := range allCtrs {
oldLocation := filepath.Join(ctr.state.RunDir, "conmon.pid")
if ctr.config.ConmonPidFile == oldLocation {
logrus.Infof("changing conmon PID file for %s", ctr.ID())
ctr.config.ConmonPidFile = filepath.Join(ctr.config.StaticDir, "conmon.pid")
if err := r.state.RewriteContainerConfig(ctr, ctr.config); err != nil {
return errors.Wrapf(err, "error rewriting config for container %s", ctr.ID())
}
}
}
for _, ctr := range runningContainers {
if err := ctr.Start(ctx, true); err != nil {
logrus.Errorf("error restarting container %s", ctr.ID())
}
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/derekhjray/podman.git
git@gitee.com:derekhjray/podman.git
derekhjray
podman
podman
v1.3.2

搜索帮助