本文整理汇总了Golang中github.com/coreos/rkt/pkg/pod.Pod.UsesOverlay方法的典型用法代码示例。如果您正苦于以下问题:Golang Pod.UsesOverlay方法的具体用法?Golang Pod.UsesOverlay怎么用?Golang Pod.UsesOverlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/rkt/pkg/pod.Pod
的用法示例。
在下文中一共展示了Pod.UsesOverlay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: deletePod
// deletePod cleans up files and resource associated with the pod
// pod must be under exclusive lock and be in either ExitedGarbage
// or Garbage state
func deletePod(p *pkgPod.Pod) {
podState := p.State()
if podState != pkgPod.ExitedGarbage && podState != pkgPod.Garbage {
stderr.Panicf("logic error: deletePod called with non-garbage pod %q (status %q)", p.UUID, p.State())
}
if podState == pkgPod.ExitedGarbage {
s, err := imagestore.NewStore(storeDir())
if err != nil {
stderr.PrintE("cannot open store", err)
return
}
defer s.Close()
ts, err := treestore.NewStore(treeStoreDir(), s)
if err != nil {
stderr.PrintE("cannot open store", err)
return
}
if globalFlags.Debug {
stage0.InitDebug()
}
if err := mountPodStage1(ts, p); err == nil {
if err = stage0.GC(p.Path(), p.UUID); err != nil {
stderr.PrintE(fmt.Sprintf("problem performing stage1 GC on %q", p.UUID), err)
}
// an overlay fs can be mounted over itself, let's unmount it here
// if we mounted it before to avoid problems when running
// stage0.MountGC
if p.UsesOverlay() {
stage1Mnt := common.Stage1RootfsPath(p.Path())
if err := syscall.Unmount(stage1Mnt, 0); err != nil {
stderr.PrintE("error unmounting stage1", err)
}
}
} else {
stderr.PrintE("skipping stage1 GC", err)
}
// unmount all leftover mounts
if err := stage0.MountGC(p.Path(), p.UUID.String()); err != nil {
stderr.PrintE(fmt.Sprintf("GC of leftover mounts for pod %q failed", p.UUID), err)
return
}
}
if err := os.RemoveAll(p.Path()); err != nil {
stderr.PrintE(fmt.Sprintf("unable to remove pod %q", p.UUID), err)
os.Exit(254)
}
}
示例2: mountPodStage1
func mountPodStage1(ts *treestore.Store, p *pkgPod.Pod) error {
if !p.UsesOverlay() {
return nil
}
s1Id, err := p.GetStage1TreeStoreID()
if err != nil {
return errwrap.Wrap(errors.New("error getting stage1 treeStoreID"), err)
}
s1rootfs := ts.GetRootFS(s1Id)
stage1Dir := common.Stage1RootfsPath(p.Path())
overlayDir := filepath.Join(p.Path(), "overlay")
imgDir := filepath.Join(overlayDir, s1Id)
upperDir := filepath.Join(imgDir, "upper")
workDir := filepath.Join(imgDir, "work")
opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", s1rootfs, upperDir, workDir)
if err := syscall.Mount("overlay", stage1Dir, "overlay", 0, opts); err != nil {
return errwrap.Wrap(errors.New("error mounting stage1"), err)
}
return nil
}