Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad-img
提交
2f9371a0
I
iSulad-img
项目概览
openeuler
/
iSulad-img
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad-img
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2f9371a0
编写于
4月 14, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
4月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
!32 calculate target size if layer blob is symlink
Merge pull request !32 from wangfengtu/symlink_size
上级
dee65e98
27e9af82
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
132 addition
and
0 deletion
+132
-0
patch/0050-calculate-target-size-if-layer-blob-is-symlink.patch
...0050-calculate-target-size-if-layer-blob-is-symlink.patch
+131
-0
patch/series-patch.conf
patch/series-patch.conf
+1
-0
未找到文件。
patch/0050-calculate-target-size-if-layer-blob-is-symlink.patch
0 → 100644
浏览文件 @
2f9371a0
From b86e9177925ee04973fab55db35952c2d4a3ebf3 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Mon, 13 Apr 2020 22:57:28 -0400
Subject: [PATCH] calculate target size if layer blob is symlink
If symlink's size is zero, it may cause the error
"Error
writing blob: blob size mismatch"
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
.../containers/image/docker/tarfile/src.go | 82 +++++++++++++++----
1 file changed, 67 insertions(+), 15 deletions(-)
diff --git a/vendor/github.com/containers/image/docker/tarfile/src.go b/vendor/github.com/containers/image/docker/tarfile/src.go
index 50c7c44..82e30a3 100644
--- a/vendor/github.com/containers/image/docker/tarfile/src.go
+++ b/vendor/github.com/containers/image/docker/tarfile/src.go
@@ -10,6 +10,7 @@
import (
"io/ioutil"
"os"
"path"
+ "path/filepath"
"github.com/containers/image/docker/reference"
"github.com/containers/image/internal/tmpdir"
@@ -335,7 +336,31 @@
func (s *Source) prepareLayerData(tarManifest *ManifestItem, parsedConfig *manif
unknownLayerSizes[layerPath] = li
}
+ calcSize := func(t *tar.Reader, name string, size int64) (int64, error) {
+ // Since GetBlob will decompress layers that are compressed we need
+ // to do the decompression here as well, otherwise we will
+ // incorrectly report the size. Pretty critical, since tools like
+ // umoci always compress layer blobs. Obviously we only bother with
+ // the slower method of checking if it's compressed.
+ uncompressedStream, isCompressed, err := compression.AutoDecompress(t)
+ if err != nil {
+ return 0, errors.Wrapf(err, "Error auto-decompressing %s to determine its size", name)
+ }
+ defer uncompressedStream.Close()
+
+ uncompressedSize := size
+ if isCompressed {
+ uncompressedSize, err = io.Copy(ioutil.Discard, uncompressedStream)
+ if err != nil {
+ return 0, errors.Wrapf(err, "Error reading %s to find its size", name)
+ }
+ }
+
+ return uncompressedSize, nil
+ }
+
// Scan the tar file to collect layer sizes.
+ symlinkSrcs := make(map[string][]string)
file, err := os.Open(s.tarPath)
if err != nil {
return nil, err
@@ -351,28 +376,55 @@
func (s *Source) prepareLayerData(tarManifest *ManifestItem, parsedConfig *manif
return nil, err
}
if li, ok := unknownLayerSizes[h.Name]; ok {
- // Since GetBlob will decompress layers that are compressed we need
- // to do the decompression here as well, otherwise we will
- // incorrectly report the size. Pretty critical, since tools like
- // umoci always compress layer blobs. Obviously we only bother with
- // the slower method of checking if it's compressed.
- uncompressedStream, isCompressed, err := compression.AutoDecompress(t)
- if err != nil {
- return nil, errors.Wrapf(err, "Error auto-decompressing %s to determine its size", h.Name)
+ // Symlink's size is zero, we need the target layer's size. We will
+ // calculate it later.
+ if h.Typeflag == tar.TypeSymlink {
+ linkname := filepath.Join(filepath.Dir(h.Name), h.Linkname)
+ symlinkSrcs[linkname] = append(symlinkSrcs[linkname], h.Name)
+ continue
}
- defer uncompressedStream.Close()
- uncompressedSize := h.Size
- if isCompressed {
- uncompressedSize, err = io.Copy(ioutil.Discard, uncompressedStream)
- if err != nil {
- return nil, errors.Wrapf(err, "Error reading %s to find its size", h.Name)
- }
+ uncompressedSize, err := calcSize(t, h.Name, h.Size)
+ if err != nil {
+ return nil, err
}
+
li.size = uncompressedSize
delete(unknownLayerSizes, h.Name)
}
}
+
+ // File symlink's size
+ tarfile, err := os.Open(s.tarPath)
+ if err != nil {
+ return nil, err
+ }
+ defer tarfile.Close()
+ t = tar.NewReader(tarfile)
+ for {
+ h, err := t.Next()
+ if err == io.EOF {
+ break
+ }
+ if err != nil {
+ return nil, err
+ }
+
+ if srcs, ok := symlinkSrcs[h.Name]; ok {
+ uncompressedSize, err := calcSize(t, h.Name, h.Size)
+ if err != nil {
+ return nil, err
+ }
+
+ for _, src := range srcs {
+ if layer, ok := unknownLayerSizes[src]; ok {
+ layer.size = uncompressedSize
+ delete(unknownLayerSizes, src)
+ }
+ }
+ }
+ }
+
if len(unknownLayerSizes) != 0 {
return nil, errors.Errorf("Some layer tarfiles are missing in the tarball") // This could do with a better error reporting, if this ever happened in practice.
}
--
2.19.1
patch/series-patch.conf
浏览文件 @
2f9371a0
...
...
@@ -47,3 +47,4 @@
0047
-
Do
-
not
-
use
-
authorization
-
file
-
of
-
other
-
container
-
eng
.
patch
0048
-
Check
-
all
-
links
-
in
-
lowers
-
file
-
but
-
not
-
parent
-
link
-
o
.
patch
0049
-
Delete
-
related
-
names
-
when
-
delete
-
layer
.
patch
0050
-
calculate
-
target
-
size
-
if
-
layer
-
blob
-
is
-
symlink
.
patch
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录