Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
e734b5be
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e734b5be
编写于
5月 03, 2019
作者:
T
Thomas Stromberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid calling Read() on 0-byte resources, and add copious debugging.
上级
d46decfb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
2 deletion
+29
-2
pkg/minikube/assets/vm_assets.go
pkg/minikube/assets/vm_assets.go
+9
-0
pkg/minikube/bootstrapper/ssh_runner.go
pkg/minikube/bootstrapper/ssh_runner.go
+20
-2
未找到文件。
pkg/minikube/assets/vm_assets.go
浏览文件 @
e734b5be
...
...
@@ -18,11 +18,13 @@ package assets
import
(
"bytes"
"fmt"
"html/template"
"io"
"os"
"path"
"github.com/golang/glog"
"github.com/pkg/errors"
)
...
...
@@ -197,6 +199,10 @@ func (m *BinDataAsset) loadData(isTemplate bool) error {
m
.
data
=
contents
m
.
Length
=
len
(
contents
)
m
.
reader
=
bytes
.
NewReader
(
m
.
data
)
glog
.
Infof
(
"Created asset %s with %d bytes"
,
m
.
AssetName
,
m
.
Length
)
if
m
.
Length
==
0
{
return
fmt
.
Errorf
(
"%s is an empty asset"
,
m
.
AssetName
)
}
return
nil
}
...
...
@@ -227,5 +233,8 @@ func (m *BinDataAsset) GetLength() int {
// Read reads the asset
func
(
m
*
BinDataAsset
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
if
m
.
Length
==
0
{
return
0
,
fmt
.
Errorf
(
"attempted read from a 0 length asset"
)
}
return
m
.
reader
.
Read
(
p
)
}
pkg/minikube/bootstrapper/ssh_runner.go
浏览文件 @
e734b5be
...
...
@@ -173,12 +173,30 @@ func (s *SSHRunner) Copy(f assets.CopyableFile) error {
// StdinPipe is closed. But let's use a WaitGroup to make it expicit.
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
var
ierr
error
var
copied
int64
go
func
()
{
defer
wg
.
Done
()
defer
w
.
Close
()
glog
.
Infof
(
"Transferring %d bytes to %s"
,
f
.
GetLength
(),
f
.
GetTargetName
())
header
:=
fmt
.
Sprintf
(
"C%s %d %s
\n
"
,
f
.
GetPermissions
(),
f
.
GetLength
(),
f
.
GetTargetName
())
fmt
.
Fprint
(
w
,
header
)
io
.
Copy
(
w
,
f
)
if
f
.
GetLength
()
==
0
{
glog
.
Warningf
(
"%s is a 0 byte asset!"
,
f
.
GetTargetName
())
fmt
.
Fprint
(
w
,
"
\x00
"
)
return
}
copied
,
ierr
=
io
.
Copy
(
w
,
f
)
if
copied
!=
int64
(
f
.
GetLength
())
{
glog
.
Warningf
(
"%s: expected to copy %d bytes, but copied %d instead"
,
f
.
GetTargetName
(),
f
.
GetLength
(),
copied
)
}
else
{
glog
.
Infof
(
"%s: copied %d bytes"
,
f
.
GetTargetName
(),
copied
)
}
if
ierr
!=
nil
{
glog
.
Errorf
(
"io.Copy failed: %v"
,
ierr
)
}
fmt
.
Fprint
(
w
,
"
\x00
"
)
}()
...
...
@@ -187,5 +205,5 @@ func (s *SSHRunner) Copy(f assets.CopyableFile) error {
return
err
}
wg
.
Wait
()
return
nil
return
ierr
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录