!112 sync some patchs form SP1
From: @panchenbo Reviewed-by: @zhong-jiawei-1, @duguhaotian Signed-off-by: @duguhaotian
This commit is contained in:
commit
1aecea47f0
@ -30,6 +30,10 @@ do
|
|||||||
if [[ "$line" =~ ^patch* ]]; then
|
if [[ "$line" =~ ^patch* ]]; then
|
||||||
echo git apply $cwd/$line
|
echo git apply $cwd/$line
|
||||||
cd $src && git apply $cwd/$line
|
cd $src && git apply $cwd/$line
|
||||||
|
elif test "$(arch)" == "sw_64" && [[ "$line" =~ ^sw64_patch* ]]; then
|
||||||
|
line=${line/#sw64_patch\//patch\/}
|
||||||
|
echo git apply "$cwd/$line"
|
||||||
|
cd "$src" && git apply "$cwd/$line"
|
||||||
fi
|
fi
|
||||||
done <"$series"
|
done <"$series"
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
Version: 1.2.0
|
Version: 1.2.0
|
||||||
Name: containerd
|
Name: containerd
|
||||||
Release: 311
|
Release: 313
|
||||||
Summary: An industry-standard container runtime
|
Summary: An industry-standard container runtime
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: https://containerd.io
|
URL: https://containerd.io
|
||||||
@ -12,6 +12,8 @@ Source2: apply-patch
|
|||||||
Source3: series.conf
|
Source3: series.conf
|
||||||
Source4: git-commit
|
Source4: git-commit
|
||||||
Source5: gen-commit.sh
|
Source5: gen-commit.sh
|
||||||
|
Source6: net.tar.gz
|
||||||
|
Source7: sys.tar.gz
|
||||||
|
|
||||||
BuildRequires: golang glibc-static make btrfs-progs-devel git
|
BuildRequires: golang glibc-static make btrfs-progs-devel git
|
||||||
|
|
||||||
@ -32,6 +34,18 @@ cp %{SOURCE4} .
|
|||||||
%build
|
%build
|
||||||
echo %{VERSION}.%{RELEASE} > containerd_version
|
echo %{VERSION}.%{RELEASE} > containerd_version
|
||||||
bash ./apply-patch
|
bash ./apply-patch
|
||||||
|
%ifarch loongarch64
|
||||||
|
rm -rf vendor/golang.org/x/sys
|
||||||
|
rm -rf vendor/golang.org/x/net
|
||||||
|
tar -xf %{SOURCE6} -C vendor/golang.org/x/
|
||||||
|
tar -xf %{SOURCE7} -C vendor/golang.org/x/
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%ifarch sw_64
|
||||||
|
cp -af %{_prefix}/lib/golang/src/cmd/vendor/golang.org/x/sys vendor/golang.org/x/
|
||||||
|
sed -i '/AAFS_MAGIC/aTIOCSWINSZ = 0x80087467' vendor/golang.org/x/sys/unix/zerrors_linux_sw64.go
|
||||||
|
sed -i '/SIGABRT /aSIGSTKFLT = syscall.Signal(0x10)' vendor/golang.org/x/sys/unix/zerrors_linux_sw64.go
|
||||||
|
%endif
|
||||||
|
|
||||||
GO_BUILD_PATH=$PWD/_build
|
GO_BUILD_PATH=$PWD/_build
|
||||||
install -m 0755 -vd $(dirname $GO_BUILD_PATH/src/%{goipath})
|
install -m 0755 -vd $(dirname $GO_BUILD_PATH/src/%{goipath})
|
||||||
@ -40,6 +54,9 @@ cd $GO_BUILD_PATH/src/%{goipath}
|
|||||||
export GO111MODULE=off
|
export GO111MODULE=off
|
||||||
export GOPATH=$GO_BUILD_PATH:%{gopath}
|
export GOPATH=$GO_BUILD_PATH:%{gopath}
|
||||||
export BUILDTAGS="no_btrfs no_cri"
|
export BUILDTAGS="no_btrfs no_cri"
|
||||||
|
%ifarch sw_64
|
||||||
|
sed -i 's/-buildmode=pie/-buildmode=exe/g' `grep buildmode=pie -rl .`
|
||||||
|
%endif
|
||||||
make
|
make
|
||||||
strip ./bin/containerd ./bin/containerd-shim ./bin/ctr
|
strip ./bin/containerd ./bin/containerd-shim ./bin/ctr
|
||||||
|
|
||||||
@ -55,12 +72,27 @@ install -p -m 755 bin/ctr $RPM_BUILD_ROOT/%{_bindir}/ctr
|
|||||||
%{_bindir}/ctr
|
%{_bindir}/ctr
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Fri Jun 16 2023 zhongjiawei<zhongjiawei1@huawei.com> - 1.2.0-311
|
* Tue Sep 19 2023 zhongjiawei<zhongjiawei1@huawei.com> - 1.2.0-313
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:sync some patches
|
||||||
|
|
||||||
|
* Thu Aug 10 2023 herengui <herengui@kylinsec.com.cn> - 1.2.0-312
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:add sw_64 support
|
||||||
|
|
||||||
|
* Sat Jun 17 2023 zhongjiawei<zhongjiawei1@huawei.com> - 1.2.0-311
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
- SUG:NA
|
- SUG:NA
|
||||||
- DESC:fix journald stop container shim log stuck bug
|
- DESC:fix journald stop container shim log stuck bug
|
||||||
|
|
||||||
|
* Tue Apr 18 2023 yangchenguang <yangchenguang@kylinsec.com.cn> - 1.2.0-310
|
||||||
|
- Sync 2203 loongarch support for containerd patch file
|
||||||
|
|
||||||
* Mon Feb 27 2023 zhongjiawei<zhongjiawei1@huawei.com> - 1.2.0-309
|
* Mon Feb 27 2023 zhongjiawei<zhongjiawei1@huawei.com> - 1.2.0-309
|
||||||
- Type:CVE
|
- Type:CVE
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
2b7c2be8c5a8368f1742ab0d5af8c296593c66ea
|
83c1d6b5231445a23935134d0cf18c2f5280ef87
|
||||||
|
|||||||
BIN
net.tar.gz
Normal file
BIN
net.tar.gz
Normal file
Binary file not shown.
@ -0,0 +1,32 @@
|
|||||||
|
From ede7f7ed58d034507643a98aeca453dba0f497fb Mon Sep 17 00:00:00 2001
|
||||||
|
From: build <build@obs.com>
|
||||||
|
Date: Thu, 5 Jan 2023 12:37:27 +0000
|
||||||
|
Subject: [PATCH] containerd add blot symbol to support loong64
|
||||||
|
|
||||||
|
---
|
||||||
|
vendor/go.etcd.io/bbolt/bolt_loong64.go | 13 +++++++++++++
|
||||||
|
1 file changed, 13 insertions(+)
|
||||||
|
create mode 100644 vendor/go.etcd.io/bbolt/bolt_loong64.go
|
||||||
|
|
||||||
|
diff --git a/vendor/go.etcd.io/bbolt/bolt_loong64.go b/vendor/go.etcd.io/bbolt/bolt_loong64.go
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..bb402fb
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/vendor/go.etcd.io/bbolt/bolt_loong64.go
|
||||||
|
@@ -0,0 +1,13 @@
|
||||||
|
+// +build loong64
|
||||||
|
+
|
||||||
|
+package bbolt
|
||||||
|
+
|
||||||
|
+// maxMapSize represents the largest mmap size supported by Bolt.
|
||||||
|
+const maxMapSize = 0x8000000000 // 512GB
|
||||||
|
+
|
||||||
|
+// maxAllocSize is the size used when creating array pointers.
|
||||||
|
+const maxAllocSize = 0x7FFFFFFF
|
||||||
|
+
|
||||||
|
+// Are unaligned load/stores broken on this arch?
|
||||||
|
+var brokenUnaligned = false
|
||||||
|
+
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
From 5c23af4ebbb9161f776833694270d5c08bd4b8df Mon Sep 17 00:00:00 2001
|
||||||
|
From: chenjiankun <chenjiankun1@huawei.com>
|
||||||
|
Date: Thu, 27 Jul 2023 15:31:32 +0800
|
||||||
|
Subject: [PATCH] docker: remove socket file when get file fd failed
|
||||||
|
|
||||||
|
if socket.File() return error, then the socket file will be left over.
|
||||||
|
---
|
||||||
|
runtime/v1/shim/client/client.go | 3 +++
|
||||||
|
1 file changed, 3 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/runtime/v1/shim/client/client.go b/runtime/v1/shim/client/client.go
|
||||||
|
index c5a9bba..4c134c2 100644
|
||||||
|
--- a/runtime/v1/shim/client/client.go
|
||||||
|
+++ b/runtime/v1/shim/client/client.go
|
||||||
|
@@ -71,6 +71,9 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
|
||||||
|
|
||||||
|
f, err := socket.File()
|
||||||
|
if err != nil {
|
||||||
|
+ if err1 := RemoveSocket(address); err1 != nil {
|
||||||
|
+ logrus.Warningf("failed to remove socket %s: %w", address, err1)
|
||||||
|
+ }
|
||||||
|
return nil, nil, errors.Wrapf(err, "failed to get fd for socket %s", address)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
35
patch/0099-containerd-diff-walking-fix-defer-cleanup.patch
Normal file
35
patch/0099-containerd-diff-walking-fix-defer-cleanup.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
From d8fe98edc34c3db927092c09af0941ca052996b9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Iceber Gu <wei.cai-nat@daocloud.io>
|
||||||
|
Date: Tue, 1 Jun 2021 18:24:47 +0800
|
||||||
|
Subject: [PATCH] diff/walking: fix defer cleanup
|
||||||
|
|
||||||
|
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
|
||||||
|
---
|
||||||
|
diff/walking/differ.go | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/diff/walking/differ.go b/diff/walking/differ.go
|
||||||
|
index 1c82860d7..988af3ccb 100644
|
||||||
|
--- a/diff/walking/differ.go
|
||||||
|
+++ b/diff/walking/differ.go
|
||||||
|
@@ -80,7 +80,7 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o
|
||||||
|
|
||||||
|
var ocidesc ocispec.Descriptor
|
||||||
|
if err := mount.WithTempMount(ctx, lower, func(lowerRoot string) error {
|
||||||
|
- return mount.WithTempMount(ctx, upper, func(upperRoot string) error {
|
||||||
|
+ return mount.WithTempMount(ctx, upper, func(upperRoot string) (retErr error) {
|
||||||
|
var newReference bool
|
||||||
|
if config.Reference == "" {
|
||||||
|
newReference = true
|
||||||
|
@@ -96,7 +96,7 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o
|
||||||
|
return errors.Wrap(err, "failed to open writer")
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
- if err != nil {
|
||||||
|
+ if retErr != nil {
|
||||||
|
cw.Close()
|
||||||
|
if newReference {
|
||||||
|
if err := s.store.Abort(ctx, config.Reference); err != nil {
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
From aa0d00674a9b836954c74dfa805798cfc267f1c2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Brown <brownwm@us.ibm.com>
|
||||||
|
Date: Thu, 3 Jun 2021 15:58:11 -0500
|
||||||
|
Subject: [PATCH] fix invalid validation error checking
|
||||||
|
|
||||||
|
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
|
||||||
|
---
|
||||||
|
metadata/containers.go | 2 +-
|
||||||
|
metadata/content.go | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/metadata/containers.go b/metadata/containers.go
|
||||||
|
index 6e5622c36..30ef44c33 100644
|
||||||
|
--- a/metadata/containers.go
|
||||||
|
+++ b/metadata/containers.go
|
||||||
|
@@ -259,7 +259,7 @@ func validateContainer(container *containers.Container) error {
|
||||||
|
|
||||||
|
// image has no validation
|
||||||
|
for k, v := range container.Labels {
|
||||||
|
- if err := labels.Validate(k, v); err == nil {
|
||||||
|
+ if err := labels.Validate(k, v); err != nil {
|
||||||
|
return errors.Wrapf(err, "containers.Labels")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/metadata/content.go b/metadata/content.go
|
||||||
|
index 8ee0f2e20..4f352ca26 100644
|
||||||
|
--- a/metadata/content.go
|
||||||
|
+++ b/metadata/content.go
|
||||||
|
@@ -689,7 +689,7 @@ func (cs *contentStore) checkAccess(ctx context.Context, dgst digest.Digest) err
|
||||||
|
|
||||||
|
func validateInfo(info *content.Info) error {
|
||||||
|
for k, v := range info.Labels {
|
||||||
|
- if err := labels.Validate(k, v); err == nil {
|
||||||
|
+ if err := labels.Validate(k, v); err != nil {
|
||||||
|
return errors.Wrapf(err, "info.Labels")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
From fc2c26175d1504b73ec63ab76d7428d53e59d180 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ningmingxiao <ning.mingxiao@zte.com.cn>
|
||||||
|
Date: Mon, 6 Dec 2021 21:36:31 +0800
|
||||||
|
Subject: [PATCH] fix Implicit memory aliasing in for loop
|
||||||
|
|
||||||
|
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
|
||||||
|
---
|
||||||
|
containerstore.go | 1 +
|
||||||
|
image_store.go | 1 +
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/containerstore.go b/containerstore.go
|
||||||
|
index 2756e2a68..bdd1c6066 100644
|
||||||
|
--- a/containerstore.go
|
||||||
|
+++ b/containerstore.go
|
||||||
|
@@ -189,6 +189,7 @@ func containersFromProto(containerspb []containersapi.Container) []containers.Co
|
||||||
|
var containers []containers.Container
|
||||||
|
|
||||||
|
for _, container := range containerspb {
|
||||||
|
+ container := container
|
||||||
|
containers = append(containers, containerFromProto(&container))
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/image_store.go b/image_store.go
|
||||||
|
index 3676bdada..7e44c73cc 100644
|
||||||
|
--- a/image_store.go
|
||||||
|
+++ b/image_store.go
|
||||||
|
@@ -129,6 +129,7 @@ func imagesFromProto(imagespb []imagesapi.Image) []images.Image {
|
||||||
|
var images []images.Image
|
||||||
|
|
||||||
|
for _, image := range imagespb {
|
||||||
|
+ image := image
|
||||||
|
images = append(images, imageFromProto(&image))
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
From 1b94345a4ce03a4ea54717df3b5a9a12a99a53cc Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Hsing-Yu (David) Chen" <davidhsingyuchen@gmail.com>
|
||||||
|
Date: Thu, 30 Mar 2023 18:38:54 -0700
|
||||||
|
Subject: [PATCH] fix: cio.Cancel() should close the pipes
|
||||||
|
|
||||||
|
PR fixes #8326.
|
||||||
|
|
||||||
|
Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>
|
||||||
|
---
|
||||||
|
cio/io_unix.go | 9 ++++++++-
|
||||||
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/cio/io_unix.go b/cio/io_unix.go
|
||||||
|
index 53b6b2dee..644e840e6 100644
|
||||||
|
--- a/cio/io_unix.go
|
||||||
|
+++ b/cio/io_unix.go
|
||||||
|
@@ -99,7 +99,14 @@ func copyIO(fifos *FIFOSet, ioset *Streams) (*cio, error) {
|
||||||
|
config: fifos.Config,
|
||||||
|
wg: wg,
|
||||||
|
closers: append(pipes.closers(), fifos),
|
||||||
|
- cancel: cancel,
|
||||||
|
+ cancel: func() {
|
||||||
|
+ cancel()
|
||||||
|
+ for _, c := range pipes.closers() {
|
||||||
|
+ if c != nil {
|
||||||
|
+ c.Close()
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ },
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
From 7ef42e9ee0640c241bd2f06c084ef3fd3171910b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Iceber Gu <wei.cai-nat@daocloud.io>
|
||||||
|
Date: Mon, 17 Apr 2023 14:02:18 +0800
|
||||||
|
Subject: [PATCH] fix unable to checkpoint the container more than once
|
||||||
|
|
||||||
|
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
|
||||||
|
---
|
||||||
|
services/tasks/local.go | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/services/tasks/local.go b/services/tasks/local.go
|
||||||
|
index 98189713e..857182b70 100644
|
||||||
|
--- a/services/tasks/local.go
|
||||||
|
+++ b/services/tasks/local.go
|
||||||
|
@@ -637,7 +637,7 @@ func (l *local) writeContent(ctx context.Context, mediaType, ref string, r io.Re
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
- if err := writer.Commit(ctx, 0, ""); err != nil {
|
||||||
|
+ if err := writer.Commit(ctx, 0, ""); err != nil && !errdefs.IsAlreadyExists(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &types.Descriptor{
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,161 @@
|
|||||||
|
From 4a8b277057b1682769aebc47f589468bda6f7a18 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Cardy.Tang" <zuniorone@gmail.com>
|
||||||
|
Date: Fri, 19 May 2023 09:49:58 +0800
|
||||||
|
Subject: [PATCH] bugfix: add nil pointer check for cgroup v1 mem usage
|
||||||
|
|
||||||
|
Signed-off-by: Cardy.Tang <zuniorone@gmail.com>
|
||||||
|
---
|
||||||
|
metrics/cgroups/memory.go | 32 ++++++++++++++++----------------
|
||||||
|
1 file changed, 16 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/metrics/cgroups/memory.go b/metrics/cgroups/memory.go
|
||||||
|
index e90295fb3..e8e9f093c 100644
|
||||||
|
--- a/metrics/cgroups/memory.go
|
||||||
|
+++ b/metrics/cgroups/memory.go
|
||||||
|
@@ -543,7 +543,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Total,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Usage == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -559,7 +559,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Usage == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -575,7 +575,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Usage == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -591,7 +591,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Usage == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -607,7 +607,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Total,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Swap == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -623,7 +623,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Swap == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -639,7 +639,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Swap == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -655,7 +655,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Swap == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -671,7 +671,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Total,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Kernel == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -687,7 +687,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Kernel == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -703,7 +703,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Kernel == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -719,7 +719,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.Kernel == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -735,7 +735,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Total,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.KernelTCP == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -751,7 +751,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.KernelTCP == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -767,7 +767,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.KernelTCP == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
@@ -783,7 +783,7 @@ var memoryMetrics = []*metric{
|
||||||
|
unit: metrics.Bytes,
|
||||||
|
vt: prometheus.GaugeValue,
|
||||||
|
getValues: func(stats *cgroups.Metrics) []value {
|
||||||
|
- if stats.Memory == nil {
|
||||||
|
+ if stats.Memory == nil || stats.Memory.KernelTCP == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return []value{
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,289 @@
|
|||||||
|
From 8c74006ac5f9175e8b253fbef58711d27ef6cb89 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Hsing-Yu (David) Chen" <davidhsingyuchen@gmail.com>
|
||||||
|
Date: Tue, 28 Mar 2023 17:13:28 -0700
|
||||||
|
Subject: [PATCH] fix: allow attaching to any combination of
|
||||||
|
stdin/stdout/stderr
|
||||||
|
|
||||||
|
Before this PR, if a stdin/stdout/stderr stream is nil,
|
||||||
|
and the corresponding FIFO is not an empty string,
|
||||||
|
a panic will occur when Read/Write of the nil stream is invoked in io.CopyBuffer.
|
||||||
|
|
||||||
|
Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>
|
||||||
|
---
|
||||||
|
cio/io.go | 9 ++
|
||||||
|
cio/io_unix_test.go | 242 ++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 251 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/cio/io.go b/cio/io.go
|
||||||
|
index a9c6d2b15..bda04d289 100644
|
||||||
|
--- a/cio/io.go
|
||||||
|
+++ b/cio/io.go
|
||||||
|
@@ -164,6 +164,15 @@ func NewAttach(opts ...Opt) Attach {
|
||||||
|
if fifos == nil {
|
||||||
|
return nil, fmt.Errorf("cannot attach, missing fifos")
|
||||||
|
}
|
||||||
|
+ if streams.Stdin == nil {
|
||||||
|
+ fifos.Stdin = ""
|
||||||
|
+ }
|
||||||
|
+ if streams.Stdout == nil {
|
||||||
|
+ fifos.Stdout = ""
|
||||||
|
+ }
|
||||||
|
+ if streams.Stderr == nil {
|
||||||
|
+ fifos.Stderr = ""
|
||||||
|
+ }
|
||||||
|
return copyIO(fifos, streams)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/cio/io_unix_test.go b/cio/io_unix_test.go
|
||||||
|
index fc2cce96d..fc186a6ec 100644
|
||||||
|
--- a/cio/io_unix_test.go
|
||||||
|
+++ b/cio/io_unix_test.go
|
||||||
|
@@ -55,3 +55,245 @@ func TestOpenFifos(t *testing.T) {
|
||||||
|
assert.Assert(t, err != nil, scenario)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+// TestOpenFifosWithTerminal tests openFifos should not open stderr if terminal
|
||||||
|
+// is set.
|
||||||
|
+func TestOpenFifosWithTerminal(t *testing.T) {
|
||||||
|
+ var ctx, cancel = context.WithCancel(context.Background())
|
||||||
|
+ defer cancel()
|
||||||
|
+
|
||||||
|
+ ioFifoDir := t.TempDir()
|
||||||
|
+
|
||||||
|
+ cfg := Config{
|
||||||
|
+ Stdout: filepath.Join(ioFifoDir, "test-stdout"),
|
||||||
|
+ Stderr: filepath.Join(ioFifoDir, "test-stderr"),
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Without terminal, pipes.Stderr should not be nil
|
||||||
|
+ {
|
||||||
|
+ p, err := openFifos(ctx, NewFIFOSet(cfg, nil))
|
||||||
|
+ if err != nil {
|
||||||
|
+ t.Fatalf("unexpected error during openFifos: %v", err)
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if p.Stderr == nil {
|
||||||
|
+ t.Fatalf("unexpected empty stderr pipe")
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // With terminal, pipes.Stderr should be nil
|
||||||
|
+ {
|
||||||
|
+ cfg.Terminal = true
|
||||||
|
+ p, err := openFifos(ctx, NewFIFOSet(cfg, nil))
|
||||||
|
+ if err != nil {
|
||||||
|
+ t.Fatalf("unexpected error during openFifos: %v", err)
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if p.Stderr != nil {
|
||||||
|
+ t.Fatalf("unexpected stderr pipe")
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+func assertHasPrefix(t *testing.T, s, prefix string) {
|
||||||
|
+ t.Helper()
|
||||||
|
+ if !strings.HasPrefix(s, prefix) {
|
||||||
|
+ t.Fatalf("expected %s to start with %s", s, prefix)
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+func TestNewFIFOSetInDir(t *testing.T) {
|
||||||
|
+ root := t.TempDir()
|
||||||
|
+
|
||||||
|
+ fifos, err := NewFIFOSetInDir(root, "theid", true)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+
|
||||||
|
+ dir := filepath.Dir(fifos.Stdin)
|
||||||
|
+ assertHasPrefix(t, dir, root)
|
||||||
|
+ expected := &FIFOSet{
|
||||||
|
+ Config: Config{
|
||||||
|
+ Stdin: filepath.Join(dir, "theid-stdin"),
|
||||||
|
+ Stdout: filepath.Join(dir, "theid-stdout"),
|
||||||
|
+ Stderr: filepath.Join(dir, "theid-stderr"),
|
||||||
|
+ Terminal: true,
|
||||||
|
+ },
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ assert.Equal(t, fifos.Config, expected.Config)
|
||||||
|
+
|
||||||
|
+ files, err := os.ReadDir(root)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ assert.Len(t, files, 1)
|
||||||
|
+
|
||||||
|
+ assert.Nil(t, fifos.Close())
|
||||||
|
+ files, err = os.ReadDir(root)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ assert.Len(t, files, 0)
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+func TestNewAttach(t *testing.T) {
|
||||||
|
+ testCases := []struct {
|
||||||
|
+ name string
|
||||||
|
+ expectedStdin, expectedStdout, expectedStderr string
|
||||||
|
+ }{
|
||||||
|
+ {
|
||||||
|
+ name: "attach to all streams (stdin, stdout, and stderr)",
|
||||||
|
+ expectedStdin: "this is the stdin",
|
||||||
|
+ expectedStdout: "this is the stdout",
|
||||||
|
+ expectedStderr: "this is the stderr",
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ name: "don't attach to stdin",
|
||||||
|
+ expectedStdout: "this is the stdout",
|
||||||
|
+ expectedStderr: "this is the stderr",
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ name: "don't attach to stdout",
|
||||||
|
+ expectedStdin: "this is the stdin",
|
||||||
|
+ expectedStderr: "this is the stderr",
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ name: "don't attach to stderr",
|
||||||
|
+ expectedStdin: "this is the stdin",
|
||||||
|
+ expectedStdout: "this is the stdout",
|
||||||
|
+ },
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for _, tc := range testCases {
|
||||||
|
+ t.Run(tc.name, func(t *testing.T) {
|
||||||
|
+ var (
|
||||||
|
+ stdin = bytes.NewBufferString(tc.expectedStdin)
|
||||||
|
+ stdout = new(bytes.Buffer)
|
||||||
|
+ stderr = new(bytes.Buffer)
|
||||||
|
+
|
||||||
|
+ // The variables below have to be of the interface type (i.e., io.Reader/io.Writer)
|
||||||
|
+ // instead of the concrete type (i.e., *bytes.Buffer) *before* being passed to NewAttach.
|
||||||
|
+ // Otherwise, in NewAttach, the interface value won't be nil
|
||||||
|
+ // (it's just that the concrete value inside the interface itself is nil. [1]),
|
||||||
|
+ // which means that the corresponding FIFO path won't be set to be an empty string,
|
||||||
|
+ // and that's not what we want.
|
||||||
|
+ //
|
||||||
|
+ // [1] https://go.dev/tour/methods/12
|
||||||
|
+ stdinArg io.Reader
|
||||||
|
+ stdoutArg, stderrArg io.Writer
|
||||||
|
+ )
|
||||||
|
+ if tc.expectedStdin != "" {
|
||||||
|
+ stdinArg = stdin
|
||||||
|
+ }
|
||||||
|
+ if tc.expectedStdout != "" {
|
||||||
|
+ stdoutArg = stdout
|
||||||
|
+ }
|
||||||
|
+ if tc.expectedStderr != "" {
|
||||||
|
+ stderrArg = stderr
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ attacher := NewAttach(WithStreams(stdinArg, stdoutArg, stderrArg))
|
||||||
|
+
|
||||||
|
+ fifos, err := NewFIFOSetInDir("", "theid", false)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+
|
||||||
|
+ attachedFifos, err := attacher(fifos)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ defer attachedFifos.Close()
|
||||||
|
+
|
||||||
|
+ producers := setupFIFOProducers(t, attachedFifos.Config())
|
||||||
|
+ initProducers(t, producers, tc.expectedStdout, tc.expectedStderr)
|
||||||
|
+
|
||||||
|
+ var actualStdin []byte
|
||||||
|
+ if producers.Stdin != nil {
|
||||||
|
+ actualStdin, err = io.ReadAll(producers.Stdin)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ attachedFifos.Wait()
|
||||||
|
+ attachedFifos.Cancel()
|
||||||
|
+ assert.Nil(t, attachedFifos.Close())
|
||||||
|
+
|
||||||
|
+ assert.Equal(t, tc.expectedStdout, stdout.String())
|
||||||
|
+ assert.Equal(t, tc.expectedStderr, stderr.String())
|
||||||
|
+ assert.Equal(t, tc.expectedStdin, string(actualStdin))
|
||||||
|
+ })
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+type producers struct {
|
||||||
|
+ Stdin io.ReadCloser
|
||||||
|
+ Stdout io.WriteCloser
|
||||||
|
+ Stderr io.WriteCloser
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+func setupFIFOProducers(t *testing.T, fifos Config) producers {
|
||||||
|
+ var (
|
||||||
|
+ err error
|
||||||
|
+ pipes producers
|
||||||
|
+ ctx = context.Background()
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ if fifos.Stdin != "" {
|
||||||
|
+ pipes.Stdin, err = fifo.OpenFifo(ctx, fifos.Stdin, syscall.O_RDONLY, 0)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if fifos.Stdout != "" {
|
||||||
|
+ pipes.Stdout, err = fifo.OpenFifo(ctx, fifos.Stdout, syscall.O_WRONLY, 0)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if fifos.Stderr != "" {
|
||||||
|
+ pipes.Stderr, err = fifo.OpenFifo(ctx, fifos.Stderr, syscall.O_WRONLY, 0)
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return pipes
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+func initProducers(t *testing.T, producers producers, stdout, stderr string) {
|
||||||
|
+ if producers.Stdout != nil {
|
||||||
|
+ _, err := producers.Stdout.Write([]byte(stdout))
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ assert.Nil(t, producers.Stdout.Close())
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if producers.Stderr != nil {
|
||||||
|
+ _, err := producers.Stderr.Write([]byte(stderr))
|
||||||
|
+ assert.NoError(t, err)
|
||||||
|
+ assert.Nil(t, producers.Stderr.Close())
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+func TestLogURIGenerator(t *testing.T) {
|
||||||
|
+ baseTestLogURIGenerator(t, []LogURIGeneratorTestCase{
|
||||||
|
+ {
|
||||||
|
+ scheme: "fifo",
|
||||||
|
+ path: "/full/path/pipe.fifo",
|
||||||
|
+ expected: "fifo:///full/path/pipe.fifo",
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ scheme: "file",
|
||||||
|
+ path: "/full/path/file.txt",
|
||||||
|
+ args: map[string]string{
|
||||||
|
+ "maxSize": "100MB",
|
||||||
|
+ },
|
||||||
|
+ expected: "file:///full/path/file.txt?maxSize=100MB",
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ scheme: "binary",
|
||||||
|
+ path: "/full/path/bin",
|
||||||
|
+ args: map[string]string{
|
||||||
|
+ "id": "testing",
|
||||||
|
+ },
|
||||||
|
+ expected: "binary:///full/path/bin?id=testing",
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ scheme: "unknown",
|
||||||
|
+ path: "nowhere",
|
||||||
|
+ err: "must be absolute",
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ scheme: "binary",
|
||||||
|
+ path: "C:\\path\\to\\binary",
|
||||||
|
+ // NOTE: Windows paths should not be parse-able outside of Windows:
|
||||||
|
+ err: "must be absolute",
|
||||||
|
+ },
|
||||||
|
+ })
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
16
patch/3000-bbolt-add-support-sw_64.patch
Normal file
16
patch/3000-bbolt-add-support-sw_64.patch
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
diff -Naur etcd-3.4.14.org/vendor/go.etcd.io/bbolt/bolt_sw64.go etcd-3.4.14.sw/vendor/go.etcd.io/bbolt/bolt_sw64.go
|
||||||
|
--- etcd-3.4.14.org/vendor/go.etcd.io/bbolt/bolt_sw64.go 1970-01-01 08:00:00.000000000 +0800
|
||||||
|
+++ etcd-3.4.14.sw/vendor/go.etcd.io/bbolt/bolt_sw64.go 2022-09-16 15:23:18.290000000 +0800
|
||||||
|
@@ -0,0 +1,12 @@
|
||||||
|
+// +build sw64
|
||||||
|
+
|
||||||
|
+package bbolt
|
||||||
|
+
|
||||||
|
+// maxMapSize represents the largest mmap size supported by Bolt.
|
||||||
|
+const maxMapSize = 0xFFFFFFFFFFFF // 256TB
|
||||||
|
+
|
||||||
|
+// maxAllocSize is the size used when creating array pointers.
|
||||||
|
+const maxAllocSize = 0x7FFFFFFF
|
||||||
|
+
|
||||||
|
+// Are unaligned load/stores broken on this arch?
|
||||||
|
+var brokenUnaligned = false
|
||||||
11
series.conf
11
series.conf
@ -101,5 +101,16 @@ patch/0093-containerd-fix-version-number-wrong.patch
|
|||||||
patch/0094-containerd-Fix-goroutine-leak-in-Exec.patch
|
patch/0094-containerd-Fix-goroutine-leak-in-Exec.patch
|
||||||
patch/0095-oci-fix-additional-GIDs.patch
|
patch/0095-oci-fix-additional-GIDs.patch
|
||||||
patch/0096-importer-stream-oci-layout-and-manifest.json.patch
|
patch/0096-importer-stream-oci-layout-and-manifest.json.patch
|
||||||
|
patch/0001-containerd-add-blot-symbol-to-support-loong64.patch
|
||||||
patch/0097-containerd-fix-journald-stop-container-shim-log-stuc.patch
|
patch/0097-containerd-fix-journald-stop-container-shim-log-stuc.patch
|
||||||
|
patch/0098-containerd-remove-socket-file-when-get-file-fd-failed.patch
|
||||||
|
patch/0099-containerd-diff-walking-fix-defer-cleanup.patch
|
||||||
|
patch/0100-containerd-fix-invalid-validation-error-checking.patch
|
||||||
|
patch/0101-containerd-fix-Implicit-memory-aliasing-in-for-loop.patch
|
||||||
|
patch/0102-contained-fix-cio.Cancel-should-close-the-pipes.patch
|
||||||
|
patch/0103-containerd-fix-unable-to-checkpoint-the-container-more-than-onc.patch
|
||||||
|
patch/0104-containerd-bugfix-add-nil-pointer-check-for-cgroup-v1-mem-usage.patch
|
||||||
|
patch/0105-containerd-fix-allow-attaching-to-any-combination-of-stdin-stdo.patch
|
||||||
|
# sw_64
|
||||||
|
sw64_patch/3000-bbolt-add-support-sw_64.patch
|
||||||
# end
|
# end
|
||||||
|
|||||||
BIN
sys.tar.gz
Normal file
BIN
sys.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user