mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-22 06:51:26 +02:00
commit
79c158b9c2
@ -1,8 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2016 CoreOS, Inc.. All rights reserved.
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header:$
|
||||
#
|
||||
|
||||
EAPI=6
|
||||
|
@ -0,0 +1,109 @@
|
||||
From a778cd1b33d191e83178879cd23732f1c106a0ef Mon Sep 17 00:00:00 2001
|
||||
From: Luca Bruno <lucab@debian.org>
|
||||
Date: Wed, 20 Sep 2017 10:10:37 +0000
|
||||
Subject: [PATCH] stage0/gc: try to avoid double overlay mounts
|
||||
|
||||
Before Linux 4.13, it used to be possible to perform double overlayfs
|
||||
mounts in place. This now fails at mount() with EBUSY.
|
||||
We were abusing this feature to unconditionally ensure that the stage1
|
||||
image overlay mount was present before calling gc entrypoint.
|
||||
This improves stage0 logic to perform the stage1 image overlay mount
|
||||
only if it doesn't already exist.
|
||||
---
|
||||
rkt/gc.go | 50 ++++++++++++++++++++++++++++++++++++--------------
|
||||
1 file changed, 36 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/rkt/gc.go b/rkt/gc.go
|
||||
index 5e025bb96..1ecdd8faf 100644
|
||||
--- a/rkt/gc.go
|
||||
+++ b/rkt/gc.go
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/rkt/rkt/common"
|
||||
+ "github.com/rkt/rkt/pkg/mountinfo"
|
||||
pkgPod "github.com/rkt/rkt/pkg/pod"
|
||||
"github.com/rkt/rkt/stage0"
|
||||
"github.com/rkt/rkt/store/imagestore"
|
||||
@@ -197,29 +198,51 @@ func emptyGarbage() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
-func mountPodStage1(ts *treestore.Store, p *pkgPod.Pod) error {
|
||||
+// mountPodStage1 tries to remount stage1 image overlay in case
|
||||
+// it is not anymore available in place (e.g. a reboot happened
|
||||
+// in-between). If an overlay mount is already there, we assume
|
||||
+// stage1 image is properly in place and we don't perform any
|
||||
+// further actions. A boolean is returned to signal whether a
|
||||
+// a new mount was performed.
|
||||
+func mountPodStage1(ts *treestore.Store, p *pkgPod.Pod) (bool, error) {
|
||||
if !p.UsesOverlay() {
|
||||
- return nil
|
||||
+ return false, nil
|
||||
}
|
||||
|
||||
s1Id, err := p.GetStage1TreeStoreID()
|
||||
if err != nil {
|
||||
- return errwrap.Wrap(errors.New("error getting stage1 treeStoreID"), err)
|
||||
+ return false, errwrap.Wrap(errors.New("error getting stage1 treeStoreID"), err)
|
||||
}
|
||||
s1rootfs := ts.GetRootFS(s1Id)
|
||||
-
|
||||
stage1Dir := common.Stage1RootfsPath(p.Path())
|
||||
+
|
||||
+ if mounts, err := mountinfo.ParseMounts(0); err == nil {
|
||||
+ for _, m := range mounts {
|
||||
+ if m.MountPoint == stage1Dir {
|
||||
+ // stage1 image overlay already in place
|
||||
+ return false, nil
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
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)
|
||||
+ err = syscall.Mount("overlay", stage1Dir, "overlay", 0, opts)
|
||||
+ if err != nil {
|
||||
+ // -EBUSY means the overlay mount is already present.
|
||||
+ // This behavior was introduced in Linux 4.13, double-mounts were allowed
|
||||
+ // in older kernels.
|
||||
+ if err == syscall.EBUSY {
|
||||
+ stderr.Println("mount detected on stage1 target, skipping overlay mount")
|
||||
+ return false, nil
|
||||
+ }
|
||||
+ return false, errwrap.Wrap(errors.New("error mounting stage1"), err)
|
||||
}
|
||||
-
|
||||
- return nil
|
||||
+ return true, nil
|
||||
}
|
||||
|
||||
// deletePod cleans up files and resource associated with the pod
|
||||
@@ -250,16 +273,15 @@ func deletePod(p *pkgPod.Pod) bool {
|
||||
stage0.InitDebug()
|
||||
}
|
||||
|
||||
- if err := mountPodStage1(ts, p); err == nil {
|
||||
+ if newMount, err := mountPodStage1(ts, p); err == nil {
|
||||
if err = stage0.GC(p.Path(), p.UUID, globalFlags.LocalConfigDir); 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() {
|
||||
+ // Linux <4.13 allows an overlay fs to be mounted over itself, so let's
|
||||
+ // unmount it here to avoid problems when running stage0.MountGC
|
||||
+ if p.UsesOverlay() && newMount {
|
||||
stage1Mnt := common.Stage1RootfsPath(p.Path())
|
||||
- if err := syscall.Unmount(stage1Mnt, 0); err != nil {
|
||||
+ if err := syscall.Unmount(stage1Mnt, 0); err != nil && err != syscall.EBUSY {
|
||||
stderr.PrintE("error unmounting stage1", err)
|
||||
}
|
||||
}
|
@ -76,6 +76,8 @@ function add_stage1() {
|
||||
}
|
||||
|
||||
src_prepare() {
|
||||
epatch "${FILESDIR}/${PN}-1.28.1-avoid-double-overlay-mounts.patch"
|
||||
|
||||
# ensure we use a CoreOS PXE image version that matches rkt's expectations.
|
||||
local rkt_coreos_version
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015 CoreOS, Inc.. All rights reserved.
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header:$
|
||||
#
|
||||
|
||||
EAPI=5
|
||||
CROS_WORKON_PROJECT="coreos/etcd"
|
||||
@ -15,7 +12,7 @@ if [[ "${PV}" == 9999 ]]; then
|
||||
CROS_WORKON_COMMIT=${CROS_WORKON_COMMIT:="HEAD"}
|
||||
KEYWORDS="~amd64 ~arm64"
|
||||
else
|
||||
CROS_WORKON_COMMIT="fd17c9101d94703f6f4c3d8d6cfb72b62b894cd7" # v2.3.7
|
||||
CROS_WORKON_COMMIT="7e4fc7eaa931298732c880a703bccc9c177ae1de" # v2.3.8
|
||||
KEYWORDS="amd64 arm64"
|
||||
fi
|
||||
|
||||
|
@ -1 +1 @@
|
||||
DIST etcdctl-3.2.6.tar.gz 2886557 SHA256 23ab4016bf0a057d36461cee001dc5b38d0d757fa5d9e8226833687dab06faa2 SHA512 3e26bc12cafbead201b41d7f25e247f24b3480ebcc76e94f2ae4e12e573a973b60e28f36fa012d1f7bc21edc670fd8910b33cd7e9f30c3a809a6f186af3ffc9d WHIRLPOOL 203833459801b18bd000bc1420f3ab14a7de601b3c18798c2537b75a510e720e5408424388bb7d643014a0de9870213533661bfad487ae30846969fdfa8efdf8
|
||||
DIST etcdctl-3.2.7.tar.gz 2886948 SHA256 b91a40102b944ba8e4dad439721c7068eccbc1d0cb0e7f2ded9dad134d2875ce SHA512 75d602d985d829455e7a10a0b347336104a0b8320949a73abd7963b08ab095e9b7cff58999ed2d365b965ba49705dff5e056e61e9a5018970a49e68278701618 WHIRLPOOL 6293415746bd6e4b943694d8a067acce59cb2850791fcef8e1a858a5b7199b9e7281228448783f1540be956e795a7a8fc729a6a4fe406b28cb1dfd5102b81cc7
|
||||
|
4
sdk_container/src/third_party/coreos-overlay/dev-db/etcdctl/metadata.xml
vendored
Normal file
4
sdk_container/src/third_party/coreos-overlay/dev-db/etcdctl/metadata.xml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
|
||||
<pkgmetadata>
|
||||
</pkgmetadata>
|
Loading…
x
Reference in New Issue
Block a user