mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix(host): clear the rootfs of container before starting (#23361)
This commit is contained in:
@@ -1296,6 +1296,9 @@ func (s *sPodGuestInstance) StartContainer(ctx context.Context, userCred mcclien
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := s.clearContainerRootFs(ctrId, input.Spec.Rootfs); err != nil {
|
||||
return nil, errors.Wrapf(err, "clear container rootfs %s before starting", jsonutils.Marshal(input.Spec.Rootfs))
|
||||
}
|
||||
if !hasCtr || needRecreate {
|
||||
log.Infof("recreate container %s before starting. hasCtr: %v, needRecreate: %v", ctrId, hasCtr, needRecreate)
|
||||
// delete and recreate the container before starting
|
||||
@@ -1497,11 +1500,6 @@ func (s *sPodGuestInstance) StopContainer(ctx context.Context, userCred mcclient
|
||||
// 后期可以添加主动通知刷新
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
if ctr := s.GetContainerById(ctrId); ctr != nil {
|
||||
if err := s.clearContainerRootFs(ctrId, ctr.Spec.Rootfs); err != nil {
|
||||
return nil, errors.Wrapf(err, "clear container rootfs %s", jsonutils.Marshal(ctr.Spec.Rootfs))
|
||||
}
|
||||
}
|
||||
if err := s.startStat.RemoveContainerFile(ctrId); err != nil {
|
||||
return nil, errors.Wrap(err, "startStat.RemoveContainerFile")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user