Browse Source

initial commit

master
Stefan Reimer 2 months ago
parent
commit
78e786853a
  1. 2
      .gitignore
  2. 28
      Makefile
  3. 24
      v1.21/cri-tools/APKBUILD
  4. 216
      v1.21/kubernetes/APKBUILD
  5. 351
      v1.21/kubernetes/Get-inodes-and-disk-usage-via-pure-go.patch
  6. 32
      v1.21/kubernetes/ensure-cgo-usage.patch
  7. 7
      v1.21/kubernetes/kube-apiserver.confd
  8. 21
      v1.21/kubernetes/kube-apiserver.initd
  9. 7
      v1.21/kubernetes/kube-apiserver.logrotated
  10. 7
      v1.21/kubernetes/kube-controller-manager.confd
  11. 19
      v1.21/kubernetes/kube-controller-manager.initd
  12. 7
      v1.21/kubernetes/kube-controller-manager.logrotated
  13. 4
      v1.21/kubernetes/kube-proxy.confd
  14. 20
      v1.21/kubernetes/kube-proxy.initd
  15. 8
      v1.21/kubernetes/kube-proxy.logrotated
  16. 7
      v1.21/kubernetes/kube-scheduler.confd
  17. 19
      v1.21/kubernetes/kube-scheduler.initd
  18. 7
      v1.21/kubernetes/kube-scheduler.logrotated
  19. 1
      v1.21/kubernetes/kubelet.confd
  20. 21
      v1.21/kubernetes/kubelet.initd
  21. 7
      v1.21/kubernetes/kubelet.logrotated
  22. 13
      v1.21/kubernetes/make-e2e_node-run-over-distro-bins.patch
  23. 19
      v1.21/kubernetes/make-test-cmd-run-over-hyperkube-based-kubectl.patch

2
.gitignore

@ -0,0 +1,2 @@
distfiles
packages

28
Makefile

@ -0,0 +1,28 @@
VERSION ?= 3.14
RELEASE := v1.21
.PHONY: builder aports_update
packages:
mkdir -p packages
distfiles:
mkdir -p distfiles
aports:
git clone git://dev.alpinelinux.org/aports --depths=1
aports_update: aports
GIT_DIR=aports/.git git fetch origin -p
GIT_DIR=aports/.git git pull origin master
# Mounts release into /work of the builder container to build all
build: packages distfiles
podman run -ti \
-v ${PWD}/distfiles:/var/cache/distfiles \
-v ${PWD}/packages:/home/alpine/packages \
-v ${HOME}/.gitconfig/:/home/alpine/.gitconfig \
-v ${HOME}/.abuild/:/home/alpine/.abuild \
-v ${PWD}/$(RELEASE)/:/home/alpine/work \
alpine-builder:${VERSION}
upload:
aws s3 cp -r

24
v1.21/cri-tools/APKBUILD

@ -0,0 +1,24 @@
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=cri-tools
pkgver=1.21.0
pkgrel=0
pkgdesc="CLI tool for Kubelet Container Runtime Interface (CRI)"
url="https://github.com/kubernetes-sigs/cri-tools"
arch="x86_64 aarch64 ppc64le s390x armv7 x86"
license="Apache-2.0"
makedepends="go"
options="!check" # no check available
source="$pkgname-$pkgver.tar.gz::https://github.com/kubernetes-sigs/cri-tools/archive/v$pkgver.tar.gz"
build() {
make all
}
package() {
install -Dm755 build/bin/crictl "$pkgdir/usr/bin/crictl"
install -Dm755 build/bin/critest "$pkgdir/usr/bin/critest"
}
sha512sums="
a307f5526fb8b7b23a1635b168a8f3b9b9b4bd6ccb94d461dc5af2065e6d1be527dadcb1c86e04808b244d0851a4901ee78a0263f58cf673f6ca503621d5eb61 cri-tools-1.21.0.tar.gz
"

216
v1.21/kubernetes/APKBUILD

@ -0,0 +1,216 @@
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Contributor: Mateusz Mikuła <matti@marinelayer.io>
# Contributor: Tiago Ilieve <tiago.myhro@gmail.com>
# Contributor: Dave <dj.2dixx@gmail.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=kubernetes
pkgver=1.21.6
pkgrel=0
pkgdesc="Container Cluster Manager"
url="https://kubernetes.io/"
arch="x86_64 aarch64 ppc64le armv7 x86"
license="Apache-2.0"
options="!check chmod-clean" # Tests hang
_kube_proxy_deps="iptables"
_kubelet_deps="iptables"
_kubeadm_deps="iproute2 socat ethtool conntrack-tools cri-tools"
makedepends="go go-bindata linux-headers rsync grep findutils bash
$_kube_proxy_deps
$_kubelet_deps
$_kubeadm_deps
"
subpackages="
kubeadm:_kubeadm
kubectl:_kubectl
kubelet:_kubelet
kubelet-openrc:_kubelet_openrc
kube-apiserver:_apiserver
kube-apiserver-openrc:_apiserver_openrc
kube-controller-manager:_controllermanager
kube-controller-manager-openrc:_controllermanager_openrc
kube-proxy:_proxy
kube-proxy-openrc:_proxy_openrc
kube-scheduler:_scheduler
kube-scheduler-openrc:_scheduler_openrc
kubeadm-bash-completion:_kubeadm_bash:noarch
kubectl-bash-completion:_kubectl_bash:noarch
"
source="$pkgname-$pkgver.tar.gz::https://github.com/kubernetes/kubernetes/archive/v$pkgver.tar.gz
ensure-cgo-usage.patch
make-e2e_node-run-over-distro-bins.patch
make-test-cmd-run-over-hyperkube-based-kubectl.patch
Get-inodes-and-disk-usage-via-pure-go.patch
kube-apiserver.initd
kube-apiserver.confd
kube-apiserver.logrotated
kube-controller-manager.initd
kube-controller-manager.confd
kube-controller-manager.logrotated
kube-proxy.initd
kube-proxy.confd
kube-proxy.logrotated
kube-scheduler.initd
kube-scheduler.confd
kube-scheduler.logrotated
kubelet.initd
kubelet.confd
kubelet.logrotated"
_agent="kubelet"
_cli="kubeadm kubectl"
_services="kube-apiserver kube-controller-manager kube-proxy kube-scheduler"
build() {
make generated_files
for _pkgs in $_agent $_cli $_services ; do
make GOFLAGS="-buildmode=pie -v -tags=providerless" GOLDFLAGS="-extldflags=-static -w -s" WHAT=cmd/$_pkgs
done
}
package() {
for bin in $_agent $_cli $_services; do
install -Dm755 _output/local/bin/linux/*/$bin "$pkgdir"/usr/bin/$bin
done
mkdir -p "$pkgdir"/etc/kubernetes
}
_do_subpkg() {
local _pkg=$1
pkgdesc="Kubernetes - $_pkg"
case "$_pkg" in
kubelet) depends="$_kubelet_deps" ;;
kubeadm) depends="$_kubeadm_deps" ;;
esac
mkdir -p "$subpkgdir"/usr/bin
mv "$pkgdir"/usr/bin/$_pkg "$subpkgdir"/usr/bin
return 0
}
_kubeadm() { _do_subpkg kubeadm; }
_kubectl() { _do_subpkg kubectl; }
_kubeadm_bash() { _do_bashcomp kubeadm; }
_kubectl_bash() { _do_bashcomp kubectl; }
_kubelet() {
_do_subpkg kubelet
install -d "$subpkgdir"/var/lib/kubelet
install -d "$subpkgdir"/var/log/kubelet
install -Dm644 "$srcdir"/kubelet.logrotated "$subpkgdir"/etc/logrotate.d/kubelet
}
_kubelet_openrc() {
pkgdesc="Kubernetes - kubelet (OpenRC init scripts)"
depends="openrc"
install_if="openrc kubelet=$pkgver-r$pkgrel"
install -Dm755 "$srcdir"/kubelet.initd "$subpkgdir"/etc/init.d/kubelet
install -Dm644 "$srcdir"/kubelet.confd "$subpkgdir"/etc/conf.d/kubelet
}
_apiserver() {
_do_subpkg kube-apiserver
install -d "$subpkgdir"/var/log/kube-apiserver
install -Dm644 "$srcdir"/kube-apiserver.logrotated "$subpkgdir"/etc/logrotate.d/kube-apiserver
}
_apiserver_openrc() {
pkgdesc="Kubernetes - kube-apiserver (OpenRC init scripts)"
depends="openrc"
install_if="openrc kube-apiserver=$pkgver-r$pkgrel"
install -Dm755 "$srcdir"/kube-apiserver.initd "$subpkgdir"/etc/init.d/kube-apiserver
install -Dm644 "$srcdir"/kube-apiserver.confd "$subpkgdir"/etc/conf.d/kube-apiserver
}
_controllermanager() {
_do_subpkg kube-controller-manager
install -d "$subpkgdir"/var/log/kube-controller-manager
install -Dm644 "$srcdir"/kube-controller-manager.logrotated "$subpkgdir"/etc/logrotate.d/kube-controller-manager
}
_controllermanager_openrc() {
pkgdesc="Kubernetes - kube-controller-manager (OpenRC init scripts)"
depends="openrc"
install_if="openrc kube-controller-manager=$pkgver-r$pkgrel"
install -Dm755 "$srcdir"/kube-controller-manager.initd "$subpkgdir"/etc/init.d/kube-controller-manager
install -Dm644 "$srcdir"/kube-controller-manager.confd "$subpkgdir"/etc/conf.d/kube-controller-manager
}
_proxy() {
_do_subpkg kube-proxy
depends="$_kube_proxy_deps"
install -d "$subpkgdir"/var/lib/kube-proxy
install -d "$subpkgdir"/var/log/kube-proxy
install -Dm644 "$srcdir"/kube-proxy.logrotated "$subpkgdir"/etc/logrotate.d/kube-proxy
}
_proxy_openrc() {
pkgdesc="Kubernetes - kube-proxy (OpenRC init scripts)"
depends="openrc"
install_if="openrc kube-proxy=$pkgver-r$pkgrel"
install -Dm755 "$srcdir"/kube-proxy.initd "$subpkgdir"/etc/init.d/kube-proxy
install -Dm644 "$srcdir"/kube-proxy.confd "$subpkgdir"/etc/conf.d/kube-proxy
}
_scheduler() {
_do_subpkg kube-scheduler
install -d "$subpkgdir"/var/log/kube-scheduler
install -Dm644 "$srcdir"/kube-scheduler.logrotated "$subpkgdir"/etc/logrotate.d/kube-scheduler
}
_scheduler_openrc() {
pkgdesc="Kubernetes - kube-scheduler (OpenRC init scripts)"
depends="openrc"
install_if="openrc kube-scheduler=$pkgver-r$pkgrel"
install -Dm755 "$srcdir"/kube-scheduler.initd "$subpkgdir"/etc/init.d/kube-scheduler
install -Dm644 "$srcdir"/kube-scheduler.confd "$subpkgdir"/etc/conf.d/kube-scheduler
}
_do_bashcomp() {
local _pkgname=$1
pkgdesc="Bash completions for $_pkgname"
install_if="$_pkgname=$pkgver-r$pkgrel bash-completion"
mkdir -p "$subpkgdir"/usr/share/bash-completion/completions
"$builddir"/_output/local/bin/linux/*/$_pkgname completion bash>"$subpkgdir"/usr/share/bash-completion/completions/$_pkgname
}
cleanup_srcdir() {
go clean -modcache
default_cleanup_srcdir
}
sha512sums="
a53dc25aa091075d73b7f8ae9a518c019a16b821bce6cfe3ff191cf4098df8851de03ec0a9292e534045323b8300532a23e6caceae3e6dfaea00471eac16a223 kubernetes-1.21.6.tar.gz
bfe072d2f53543b8d704319755f3cfe5ed2467b54879e22117a25a9d7d6d4d238356e45824deaf4d18b8e9eb6f34d1de43be4840b9906f7909478ffe9e8a65ff ensure-cgo-usage.patch
052a0b06de417704f87361f00195063d1aaba0e12ae80a21342613061df2b37b908265e7375604d5f6283767da45363310ec1d9f9e0c17aa616c040c8ecbb267 make-e2e_node-run-over-distro-bins.patch
56201491d2dfe3a487931cbf5c6e60af898701b9541a936d80e3823948fcfb98508e3d51f4aaa415ce971f7bd20a7b51f74f025c76b83f58d5a8de8ce0ab679b make-test-cmd-run-over-hyperkube-based-kubectl.patch
f38dde9c464a09615854bd80521f1f9b83cb96adf7d99b31c3e3f7c566cfc525f88eef7d5a447ace03c65678e7d575529d54f5974b1b1b5183b46b216cbecf5e Get-inodes-and-disk-usage-via-pure-go.patch
e690daff2adb1013c92124f32e71f8ed9a18c611ae6ae5fcb5ce9674768dbf9d911a05d7e4028488cda886e63b82e8ac0606d14389a05844c1b5538a33dd09d1 kube-apiserver.initd
302b2a7ec715967c0aa7d1c177d4e55b26e37ebba8d04dd37ecf627d20042fe91cd7e6192ff9d71422129b0ea54a9eec6046f505af550548bd450998924f37ee kube-apiserver.confd
1a4bcd54dafaedc614e34bbadc2a1163f003b5925d47552fb2c47049c033c147e612171e263d9659d189fc2d95688a0b7153322d8dba97c083c079fdef6c400e kube-apiserver.logrotated
90b9a9708e6d7c9084de17c8b28cbf6ff543400128d47f4d168883d8d3461b4dcbbb1796950a12ffc79b0f341b3881b48bba7651e3c232c1731a7e6dbddb62b8 kube-controller-manager.initd
347dcf514abec4bc94036955d0fb2d32f141a39d1a70d7fb37e7bf8eb5792e5c29560d500a08aafcd3e19422d04466004b832bca7108eb2815610feb144688fe kube-controller-manager.confd
e00cd9297d8ac75fcd504a2bfb80d5c5e145e7d475dd15edf9361dc28721afdc069c5b6e79438b75a774e972028841a17e8f7842dcfb3d7835c436a3e503704c kube-controller-manager.logrotated
cd43587f69bd9fc6f1fdf0896d99df89377f677f4fa9b367dcaee1bf6f66469577dd79c60833ba0cd60ffdb68deedd0fb9bc00caa2b06854af4e6e56f1ffe365 kube-proxy.initd
4c8c34ae8668bcfa5167c2d2af006fc46b461a5dafb3ec5b64cb8cdf2a830c22ddb5cf806c93b1404f60dabf91b4153724947fa2d2c494376f20e637eeed5018 kube-proxy.confd
d7e022ee22da191bda7382f87cb293d9c9d115a3df0c2054bf918279eb866f99c6d5c21e4c98eae84bacf925f7793bbe3087e0bcf6732ccb33844d15e4386fb5 kube-proxy.logrotated
561bef5633ba4b9021720624443d9c279a561e5fabea76e5d0fbee2e7ad8999029a2511a45895fbec8448026212a3c5b4c197b248a6afa7f8bd945f705524ea7 kube-scheduler.initd
af88b382ab75657d0ff13c3f8f6d924cef9f2df7807a9a27daa63495981801bc4b607998f65c0758c11a7e070e43c24f7184ba7720711109c74b1c4d57919e34 kube-scheduler.confd
3692da349dd6ed0f5acc09d7b95ac562ffecb103e2270bebdfe4a7808d48dada9d2debff262d85b11c47f9ca3f0c20000712d03629ed813ff08a3e02d69267e6 kube-scheduler.logrotated
70fb5c95a02083025f38b099fa50d1a1e8893bc4141955031c4129c0d4aa20fde05c565c3f2e5b6ea31efb954673aeb8289f22eadcedeb7cb89e197898dfc65d kubelet.initd
e6a1d33e8b986b076fd7144ed74abda6aed20d45c138dca6d88c5a27fbf61d6bf10c4b8530b8c7a1ea9df63deb70ab47273142169e79e0b3c7a135d0b11017ec kubelet.confd
dda5fb57b55926fd2e9cebe6c1593da699afba0398c58dfa8b923c53a9ae6e63d765778577211460047f20863a6095e8e2ab3e7769e38c4f6a1c55c0e3485501 kubelet.logrotated
"

351
v1.21/kubernetes/Get-inodes-and-disk-usage-via-pure-go.patch

@ -0,0 +1,351 @@
upstream: https://github.com/kubernetes/kubernetes/pull/96115
From d45ba645a8f7b288284890a051c73bbae717da4b Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@mirantis.com>
Date: Wed, 30 Sep 2020 15:19:27 +0200
Subject: [PATCH] Get inodes and disk usage via pure go
Fix inode usage calculation to use filepath.Walk instead of executing an
external find. Also calculate the disk usage while at it so we also get
rid of the external dependency of `nice` and `du`. (#95172)
This is similar to what cadvisor does since commit
https://github.com/google/cadvisor/commit/046818d64c0af62a4c5037583b467296bb68626d
This solves three problems:
- Counts number of inodes correct when there are hardlinks (#96114)
- Makes kubelet work without GNU findutils (#95186)
- Makes kubelet work without GNU coreutils (#95172)
---
pkg/volume/metrics_du.go | 26 ++---
pkg/volume/util/fs/fs.go | 132 +++++++++++++++-----------
pkg/volume/util/fs/fs_unsupported.go | 17 ++--
pkg/volume/util/fs/fs_windows.go | 30 ++----
pkg/volume/util/fs/fs_windows_test.go | 7 +-
5 files changed, 108 insertions(+), 104 deletions(-)
diff --git a/pkg/volume/metrics_du.go b/pkg/volume/metrics_du.go
index 1491c30de76d83..f080fac2b33bce 100644
--- a/pkg/volume/metrics_du.go
+++ b/pkg/volume/metrics_du.go
@@ -46,12 +46,7 @@ func (md *metricsDu) GetMetrics() (*Metrics, error) {
return metrics, NewNoPathDefinedError()
}
- err := md.runDiskUsage(metrics)
- if err != nil {
- return metrics, err
- }
-
- err = md.runFind(metrics)
+ err := md.getDiskUsage(metrics)
if err != nil {
return metrics, err
}
@@ -64,23 +59,14 @@ func (md *metricsDu) GetMetrics() (*Metrics, error) {
return metrics, nil
}
-// runDiskUsage gets disk usage of md.path and writes the results to metrics.Used
-func (md *metricsDu) runDiskUsage(metrics *Metrics) error {
- used, err := fs.DiskUsage(md.path)
- if err != nil {
- return err
- }
- metrics.Used = used
- return nil
-}
-
-// runFind executes the "find" command and writes the results to metrics.InodesUsed
-func (md *metricsDu) runFind(metrics *Metrics) error {
- inodesUsed, err := fs.Find(md.path)
+// getDiskUsage writes metrics.Used and metric.InodesUsed from fs.DiskUsage
+func (md *metricsDu) getDiskUsage(metrics *Metrics) error {
+ usage, err := fs.DiskUsage(md.path)
if err != nil {
return err
}
- metrics.InodesUsed = resource.NewQuantity(inodesUsed, resource.BinarySI)
+ metrics.Used = resource.NewQuantity(usage.Bytes, resource.BinarySI)
+ metrics.InodesUsed = resource.NewQuantity(usage.Inodes, resource.BinarySI)
return nil
}
diff --git a/pkg/volume/util/fs/fs.go b/pkg/volume/util/fs/fs.go
index a6114f259a6637..77adf3747856ea 100644
--- a/pkg/volume/util/fs/fs.go
+++ b/pkg/volume/util/fs/fs.go
@@ -19,17 +19,21 @@ limitations under the License.
package fs
import (
- "bytes"
"fmt"
- "os/exec"
- "strings"
+ "os"
+ "path/filepath"
+ "syscall"
"golang.org/x/sys/unix"
- "k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/volume/util/fsquota"
)
+type UsageInfo struct {
+ Bytes int64
+ Inodes int64
+}
+
// Info linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
// for the filesystem that path resides upon.
func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
@@ -55,63 +59,83 @@ func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
return available, capacity, usage, inodes, inodesFree, inodesUsed, nil
}
-// DiskUsage gets disk usage of specified path.
-func DiskUsage(path string) (*resource.Quantity, error) {
- // First check whether the quota system knows about this directory
- // A nil quantity with no error means that the path does not support quotas
- // and we should use other mechanisms.
- data, err := fsquota.GetConsumption(path)
- if data != nil {
- return data, nil
- } else if err != nil {
- return nil, fmt.Errorf("unable to retrieve disk consumption via quota for %s: %v", path, err)
- }
- // Uses the same niceness level as cadvisor.fs does when running du
- // Uses -B 1 to always scale to a blocksize of 1 byte
- out, err := exec.Command("nice", "-n", "19", "du", "-x", "-s", "-B", "1", path).CombinedOutput()
- if err != nil {
- return nil, fmt.Errorf("failed command 'du' ($ nice -n 19 du -x -s -B 1) on path %s with error %v", path, err)
- }
- used, err := resource.ParseQuantity(strings.Fields(string(out))[0])
- if err != nil {
- return nil, fmt.Errorf("failed to parse 'du' output %s due to error %v", out, err)
- }
- used.Format = resource.BinarySI
- return &used, nil
-}
+// DiskUsage calculates the number of inodes and disk usage for a given directory
+func DiskUsage(path string) (UsageInfo, error) {
+ var usage UsageInfo
-// Find uses the equivalent of the command `find <path> -dev -printf '.' | wc -c` to count files and directories.
-// While this is not an exact measure of inodes used, it is a very good approximation.
-func Find(path string) (int64, error) {
if path == "" {
- return 0, fmt.Errorf("invalid directory")
+ return usage, fmt.Errorf("invalid directory")
}
+
// First check whether the quota system knows about this directory
- // A nil quantity with no error means that the path does not support quotas
- // and we should use other mechanisms.
- inodes, err := fsquota.GetInodes(path)
- if inodes != nil {
- return inodes.Value(), nil
- } else if err != nil {
- return 0, fmt.Errorf("unable to retrieve inode consumption via quota for %s: %v", path, err)
+ // A nil quantity or error means that the path does not support quotas
+ // or xfs_quota tool is missing and we should use other mechanisms.
+ consumption, _ := fsquota.GetConsumption(path)
+ if consumption != nil {
+ usage.Bytes = consumption.Value()
}
- var counter byteCounter
- var stderr bytes.Buffer
- findCmd := exec.Command("find", path, "-xdev", "-printf", ".")
- findCmd.Stdout, findCmd.Stderr = &counter, &stderr
- if err := findCmd.Start(); err != nil {
- return 0, fmt.Errorf("failed to exec cmd %v - %v; stderr: %v", findCmd.Args, err, stderr.String())
+
+ inodes, _ := fsquota.GetInodes(path)
+ if inodes != nil {
+ usage.Inodes = inodes.Value()
}
- if err := findCmd.Wait(); err != nil {
- return 0, fmt.Errorf("cmd %v failed. stderr: %s; err: %v", findCmd.Args, stderr.String(), err)
+
+ if inodes != nil && consumption != nil {
+ return usage, nil
}
- return counter.bytesWritten, nil
-}
-// Simple io.Writer implementation that counts how many bytes were written.
-type byteCounter struct{ bytesWritten int64 }
+ topLevelStat := &unix.Stat_t{}
+ err := unix.Stat(path, topLevelStat)
+ if err != nil {
+ return usage, err
+ }
-func (b *byteCounter) Write(p []byte) (int, error) {
- b.bytesWritten += int64(len(p))
- return len(p), nil
+ // dedupedInode stores inodes that could be duplicates (nlink > 1)
+ dedupedInodes := make(map[uint64]struct{})
+
+ err = filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
+ // ignore files that have been deleted after directory was read
+ if os.IsNotExist(err) {
+ return nil
+ }
+ if err != nil {
+ return fmt.Errorf("unable to count inodes for %s: %s", path, err)
+ }
+
+ // according to the docs, Sys can be nil
+ if info.Sys() == nil {
+ return fmt.Errorf("fileinfo Sys is nil")
+ }
+
+ s, ok := info.Sys().(*syscall.Stat_t)
+ if !ok {
+ return fmt.Errorf("unsupported fileinfo; could not convert to stat_t")
+ }
+
+ if s.Dev != topLevelStat.Dev {
+ // don't descend into directories on other devices
+ return filepath.SkipDir
+ }
+
+ // Dedupe hardlinks
+ if s.Nlink > 1 {
+ if _, ok := dedupedInodes[s.Ino]; !ok {
+ dedupedInodes[s.Ino] = struct{}{}
+ } else {
+ return nil
+ }
+ }
+
+ if consumption == nil {
+ usage.Bytes += int64(s.Blocks) * int64(512) // blocksize in bytes
+ }
+
+ if inodes == nil {
+ usage.Inodes++
+ }
+
+ return nil
+ })
+
+ return usage, err
}
diff --git a/pkg/volume/util/fs/fs_unsupported.go b/pkg/volume/util/fs/fs_unsupported.go
index 8cadf72bd53e79..6a098cb3f55f65 100644
--- a/pkg/volume/util/fs/fs_unsupported.go
+++ b/pkg/volume/util/fs/fs_unsupported.go
@@ -20,21 +20,20 @@ package fs
import (
"fmt"
-
- "k8s.io/apimachinery/pkg/api/resource"
)
+type UsageInfo struct {
+ Bytes int64
+ Inodes int64
+}
+
// Info unsupported returns 0 values for available and capacity and an error.
func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
return 0, 0, 0, 0, 0, 0, fmt.Errorf("fsinfo not supported for this build")
}
// DiskUsage gets disk usage of specified path.
-func DiskUsage(path string) (*resource.Quantity, error) {
- return nil, fmt.Errorf("du not supported for this build")
-}
-
-// Find will always return zero since is on unsupported platform.
-func Find(path string) (int64, error) {
- return 0, fmt.Errorf("find not supported for this build")
+func DiskUsage(path string) (UsageInfo, error) {
+ var usage UsageInfo
+ return usage, fmt.Errorf("directory disk usage not supported for this build.")
}
diff --git a/pkg/volume/util/fs/fs_windows.go b/pkg/volume/util/fs/fs_windows.go
index 8d16eabcefeccb..356b2e223bff2d 100644
--- a/pkg/volume/util/fs/fs_windows.go
+++ b/pkg/volume/util/fs/fs_windows.go
@@ -26,8 +26,6 @@ import (
"unsafe"
"golang.org/x/sys/windows"
-
- "k8s.io/apimachinery/pkg/api/resource"
)
var (
@@ -35,6 +33,11 @@ var (
procGetDiskFreeSpaceEx = modkernel32.NewProc("GetDiskFreeSpaceExW")
)
+type UsageInfo struct {
+ Bytes int64
+ Inodes int64
+}
+
// Info returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
// for the filesystem that path resides upon.
func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
@@ -64,28 +67,15 @@ func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
}
// DiskUsage gets disk usage of specified path.
-func DiskUsage(path string) (*resource.Quantity, error) {
+func DiskUsage(path string) (UsageInfo, error) {
+ var usage UsageInfo
info, err := os.Lstat(path)
if err != nil {
- return nil, err
- }
-
- usage, err := diskUsage(path, info)
- if err != nil {
- return nil, err
+ return usage, err
}
- used, err := resource.ParseQuantity(fmt.Sprintf("%d", usage))
- if err != nil {
- return nil, fmt.Errorf("failed to parse fs usage %d due to %v", usage, err)
- }
- used.Format = resource.BinarySI
- return &used, nil
-}
-
-// Find will always return zero since inodes is not supported on Windows.
-func Find(path string) (int64, error) {
- return 0, nil
+ usage.Bytes, err = diskUsage(path, info)
+ return usage, err
}
func diskUsage(currPath string, info os.FileInfo) (int64, error) {
diff --git a/pkg/volume/util/fs/fs_windows_test.go b/pkg/volume/util/fs/fs_windows_test.go
index df57d82b548546..c9f69ba6941faa 100644
--- a/pkg/volume/util/fs/fs_windows_test.go
+++ b/pkg/volume/util/fs/fs_windows_test.go
@@ -67,10 +67,15 @@ func TestDiskUsage(t *testing.T) {
}
total := dirInfo1.Size() + dirInfo2.Size() + fileInfo1.Size() + fileInfo2.Size()
- size, err := DiskUsage(dir1)
+ usage, err := DiskUsage(dir1)
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}
+ size, err := resource.ParseQuantity(fmt.Sprintf("%d", usage.Bytes))
+ if err != nil {
+ t.Fatalf("TestDiskUsage failed: %s", err.Error())
+ }
+
used, err := resource.ParseQuantity(fmt.Sprintf("%d", total))
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())

32
v1.21/kubernetes/ensure-cgo-usage.patch

@ -0,0 +1,32 @@
From: Tiago Ilieve <tiago.myhro@gmail.com>
Date: Sat, 27 Oct 2018 10:47:42 +0000
Subject: [PATCH] Ensure CGO usage
There are checks to define if CGO is required by the platform, but those
are not enough to ensure its usage in Alpine. This leads to errors like:
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x8): undefined reference to `x_cgo_callers'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x10): undefined reference to `x_cgo_init'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x18): undefined reference to `x_cgo_mmap'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x20): undefined reference to `x_cgo_munmap'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x28): undefined reference to `x_cgo_notify_runtime_init_done'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x30): undefined reference to `x_cgo_sigaction'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x38): undefined reference to `x_cgo_thread_start'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x5b0): undefined reference to `x_cgo_setenv'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x5b8): undefined reference to `x_cgo_unsetenv'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /tmp/go-link-879017147/go.o:(.data+0x5c0): undefined reference to `_cgo_yield'
collect2: error: ld returned 1 exit status
---
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -611,7 +611,7 @@
-asmflags "${goasmflags:-}"
-ldflags "${goldflags:-}"
)
- CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
+ CGO_ENABLED=1 kube::golang::build_some_binaries "${statics[@]}"
fi
if [[ "${#nonstatics[@]}" != 0 ]]; then

7
v1.21/kubernetes/kube-apiserver.confd

@ -0,0 +1,7 @@
###
# kubernetes system config
#
# The following values are used to configure the kube-apiserver
#
command_args=""

21
v1.21/kubernetes/kube-apiserver.initd

@ -0,0 +1,21 @@
#!/sbin/openrc-run
# Copyright 2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
supervisor=supervise-daemon
description="Kubernetes API Server"
if [ -e /var/lib/kubernetes/kube-apiserver-flags.env ]; then
. /var/lib/kubernetes/kube-apiserver-flags.env;
fi
command="/usr/bin/kube-apiserver"
command_args="${command_args} ${KUBE_APISERVER_ARGS}"
: ${output_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
: ${error_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
depend() {
after net
}

7
v1.21/kubernetes/kube-apiserver.logrotated

@ -0,0 +1,7 @@
/var/log/kube-apiserver/*.log {
missingok
size 5M
rotate 3
compress
copytruncate
}

7
v1.21/kubernetes/kube-controller-manager.confd

@ -0,0 +1,7 @@
###
# kubernetes system config
#
# The following values are used to configure the kube-controller-manager
#
command_args=""

19
v1.21/kubernetes/kube-controller-manager.initd

@ -0,0 +1,19 @@
#!/sbin/openrc-run
# Copyright 2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
supervisor=supervise-daemon
description="Kubernetes Controller Manager service"
if [ -e /var/lib/kubernetes/kube-controller-manager-flags.env ]; then
. /var/lib/kubernetes/kube-controller-manager-flags.env;
fi
command="/usr/bin/kube-controller-manager"
command_args="${command_args} ${KUBE_CONTROLLER_MANAGER_ARGS}"
: ${output_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
: ${error_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
depend() {
after net
}

7
v1.21/kubernetes/kube-controller-manager.logrotated

@ -0,0 +1,7 @@
/var/log/kube-controller-manager/*.log {
missingok
size 5M
rotate 3
compress
copytruncate
}

4
v1.21/kubernetes/kube-proxy.confd

@ -0,0 +1,4 @@
###
# Kubernetes kube-proxy config
#
command_args=""

20
v1.21/kubernetes/kube-proxy.initd

@ -0,0 +1,20 @@
#!/sbin/openrc-run
# Copyright 2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
supervisor=supervise-daemon
description="Kubernetes Proxy service"
if [ -e /var/lib/kubernetes/kube-proxy-flags.env ]; then
. /var/lib/kubernetes/kube-proxy-flags.env;
fi
command="/usr/bin/kube-proxy"
command_args="${command_args} ${KUBE_PROXY_ARGS}"
: ${output_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
: ${error_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
depend() {
after net
}

8
v1.21/kubernetes/kube-proxy.logrotated

@ -0,0 +1,8 @@
/var/log/kube-proxy/*.log {
missingok
size 5M
rotate 3
compress
copytruncate
}

7
v1.21/kubernetes/kube-scheduler.confd

@ -0,0 +1,7 @@
###
# kubernetes system config
#
# The following values are used to configure the kube-scheduler
#
command_args=""

19
v1.21/kubernetes/kube-scheduler.initd

@ -0,0 +1,19 @@
#!/sbin/openrc-run
# Copyright 2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
supervisor=supervise-daemon
description="Kubernetes Scheduler service"
if [ -e /var/lib/kubernetes/kube-scheduler-flags.env ]; then
. /var/lib/kubernetes/kube-scheduler-flags.env;
fi
command="/usr/bin/kube-scheduler"
command_args="${command_args} ${KUBE_SCHEDULER_ARGS}"
: ${output_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
: ${error_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
depend() {
after net
}

7
v1.21/kubernetes/kube-scheduler.logrotated

@ -0,0 +1,7 @@
/var/log/kube-scheduler/*.log {
missingok
size 5M
rotate 3
compress
copytruncate
}

1
v1.21/kubernetes/kubelet.confd

@ -0,0 +1 @@
command_args="--cni-bin-dir=/usr/libexec/cni --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml"

21
v1.21/kubernetes/kubelet.initd

@ -0,0 +1,21 @@
#!/sbin/openrc-run
# Copyright 2016-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
supervisor=supervise-daemon
description="Kubelet, a Kubernetes node agent"
if [ -e /var/lib/kubelet/kubeadm-flags.env ]; then
. /var/lib/kubelet/kubeadm-flags.env;
fi
command="/usr/bin/kubelet"
command_args="${command_args} ${KUBELET_KUBEADM_ARGS}"
pidfile="${KUBELET_PIDFILE:-/run/${RC_SVCNAME}.pid}"
: ${output_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
: ${error_log:=/var/log/$RC_SVCNAME/$RC_SVCNAME.log}
depend() {
after net
need cgroups
}

7
v1.21/kubernetes/kubelet.logrotated

@ -0,0 +1,7 @@
/var/log/kubelet/*.log {
missingok
size 5M
rotate 3
compress
copytruncate
}

13
v1.21/kubernetes/make-e2e_node-run-over-distro-bins.patch

@ -0,0 +1,13 @@
diff --git a/hack/make-rules/test-e2e-node.sh b/hack/make-rules/test-e2e-node.sh
index f72ced2a..de4ab961 100755
--- a/hack/make-rules/test-e2e-node.sh
+++ b/hack/make-rules/test-e2e-node.sh
@@ -206,6 +206,7 @@ else
--ginkgo-flags="${ginkgoflags}" --test-flags="--container-runtime=${runtime} \
--alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \
${test_args}" --runtime-config="${runtime_config}" \
- --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
+ --k8s-bin-dir "/usr/bin" --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
+
exit $?
fi

19
v1.21/kubernetes/make-test-cmd-run-over-hyperkube-based-kubectl.patch

@ -0,0 +1,19 @@
diff --git a/hack/lib/test.sh b/hack/lib/test.sh
index 62a6765f..775d1d96 100644
--- a/hack/lib/test.sh
+++ b/hack/lib/test.sh
@@ -77,12 +77,12 @@ kube::test::object_assert() {
local object=$2
local request=$3
local expected=$4
- local args=${5:-}
+ local get_args=${5:-}
for j in $(seq 1 "${tries}"); do
# shellcheck disable=SC2086
# Disabling because "args" needs to allow for expansion here
- res=$(eval kubectl get "${kube_flags[@]}" ${args} "${object}" -o go-template=\""${request}"\")
+ res=$(eval kubectl ${args} get "${kube_flags[@]}" ${get_args} "${object}" -o go-template=\""${request}"\")
if [[ "${res}" =~ ^$expected$ ]]; then
echo -n "${green}"
echo "$(kube::test::get_caller 3): Successful get ${object} ${request}: ${res}"
Loading…
Cancel
Save