Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
b398810a
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
b398810a
编写于
11月 25, 2019
作者:
M
Medya Ghazizadeh
提交者:
GitHub
11月 25, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5917 from tstromberg/include-output-exec-err
SSHRunner: include stdout/stderr with error message
上级
f4c9d617
7f97b91a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
24 deletion
+26
-24
pkg/minikube/command/exec_runner.go
pkg/minikube/command/exec_runner.go
+13
-12
pkg/minikube/command/ssh_runner.go
pkg/minikube/command/ssh_runner.go
+13
-12
未找到文件。
pkg/minikube/command/exec_runner.go
浏览文件 @
b398810a
...
@@ -18,6 +18,7 @@ package command
...
@@ -18,6 +18,7 @@ package command
import
(
import
(
"bytes"
"bytes"
"fmt"
"io"
"io"
"os"
"os"
"os/exec"
"os/exec"
...
@@ -39,7 +40,7 @@ type ExecRunner struct{}
...
@@ -39,7 +40,7 @@ type ExecRunner struct{}
// RunCmd implements the Command Runner interface to run a exec.Cmd object
// RunCmd implements the Command Runner interface to run a exec.Cmd object
func
(
*
ExecRunner
)
RunCmd
(
cmd
*
exec
.
Cmd
)
(
*
RunResult
,
error
)
{
func
(
*
ExecRunner
)
RunCmd
(
cmd
*
exec
.
Cmd
)
(
*
RunResult
,
error
)
{
rr
:=
&
RunResult
{
Args
:
cmd
.
Args
}
rr
:=
&
RunResult
{
Args
:
cmd
.
Args
}
glog
.
Infof
(
"
(ExecRunner) Run:
%v"
,
rr
.
Command
())
glog
.
Infof
(
"
Run:
%v"
,
rr
.
Command
())
var
outb
,
errb
io
.
Writer
var
outb
,
errb
io
.
Writer
if
cmd
.
Stdout
==
nil
{
if
cmd
.
Stdout
==
nil
{
...
@@ -62,19 +63,19 @@ func (*ExecRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
...
@@ -62,19 +63,19 @@ func (*ExecRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
start
:=
time
.
Now
()
start
:=
time
.
Now
()
err
:=
cmd
.
Run
()
err
:=
cmd
.
Run
()
elapsed
:=
time
.
Since
(
start
)
elapsed
:=
time
.
Since
(
start
)
if
exitError
,
ok
:=
err
.
(
*
exec
.
ExitError
);
ok
{
rr
.
ExitCode
=
exitError
.
ExitCode
()
}
// Decrease log spam
if
elapsed
>
(
1
*
time
.
Second
)
{
glog
.
Infof
(
"Completed: %s: (%s)"
,
rr
.
Command
(),
elapsed
)
}
if
err
==
nil
{
if
err
==
nil
{
// Reduce log spam
return
rr
,
nil
if
elapsed
>
(
1
*
time
.
Second
)
{
glog
.
Infof
(
"(ExecRunner) Done: %v: (%s)"
,
rr
.
Command
(),
elapsed
)
}
}
else
{
if
exitError
,
ok
:=
err
.
(
*
exec
.
ExitError
);
ok
{
rr
.
ExitCode
=
exitError
.
ExitCode
()
}
glog
.
Infof
(
"(ExecRunner) Non-zero exit: %v: %v (%s)
\n
%s"
,
rr
.
Command
(),
err
,
elapsed
,
rr
.
Output
())
err
=
errors
.
Wrapf
(
err
,
"command failed: %s
\n
stdout: %s
\n
stderr: %s"
,
rr
.
Command
(),
rr
.
Stdout
.
String
(),
rr
.
Stderr
.
String
())
}
}
return
rr
,
err
return
rr
,
fmt
.
Errorf
(
"%s: %v
\n
stdout:
\n
%s
\n
stderr:
\n
%s"
,
rr
.
Command
(),
err
,
rr
.
Stdout
.
String
(),
rr
.
Stderr
.
String
())
}
}
// Copy copies a file and its permissions
// Copy copies a file and its permissions
...
...
pkg/minikube/command/ssh_runner.go
浏览文件 @
b398810a
...
@@ -99,7 +99,7 @@ func teeSSH(s *ssh.Session, cmd string, outB io.Writer, errB io.Writer) error {
...
@@ -99,7 +99,7 @@ func teeSSH(s *ssh.Session, cmd string, outB io.Writer, errB io.Writer) error {
// RunCmd implements the Command Runner interface to run a exec.Cmd object
// RunCmd implements the Command Runner interface to run a exec.Cmd object
func
(
s
*
SSHRunner
)
RunCmd
(
cmd
*
exec
.
Cmd
)
(
*
RunResult
,
error
)
{
func
(
s
*
SSHRunner
)
RunCmd
(
cmd
*
exec
.
Cmd
)
(
*
RunResult
,
error
)
{
rr
:=
&
RunResult
{
Args
:
cmd
.
Args
}
rr
:=
&
RunResult
{
Args
:
cmd
.
Args
}
glog
.
Infof
(
"
(SSHRunner) Run:
%v"
,
rr
.
Command
())
glog
.
Infof
(
"
Run:
%v"
,
rr
.
Command
())
var
outb
,
errb
io
.
Writer
var
outb
,
errb
io
.
Writer
start
:=
time
.
Now
()
start
:=
time
.
Now
()
...
@@ -131,20 +131,21 @@ func (s *SSHRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
...
@@ -131,20 +131,21 @@ func (s *SSHRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
}
}
}()
}()
elapsed
:=
time
.
Since
(
start
)
err
=
teeSSH
(
sess
,
shellquote
.
Join
(
cmd
.
Args
...
),
outb
,
errb
)
err
=
teeSSH
(
sess
,
shellquote
.
Join
(
cmd
.
Args
...
),
outb
,
errb
)
elapsed
:=
time
.
Since
(
start
)
if
exitError
,
ok
:=
err
.
(
*
exec
.
ExitError
);
ok
{
rr
.
ExitCode
=
exitError
.
ExitCode
()
}
// Decrease log spam
if
elapsed
>
(
1
*
time
.
Second
)
{
glog
.
Infof
(
"Completed: %s: (%s)"
,
rr
.
Command
(),
elapsed
)
}
if
err
==
nil
{
if
err
==
nil
{
// Reduce log spam
return
rr
,
nil
if
elapsed
>
(
1
*
time
.
Second
)
{
glog
.
Infof
(
"(SSHRunner) Done: %v: (%s)"
,
rr
.
Command
(),
elapsed
)
}
}
else
{
if
exitError
,
ok
:=
err
.
(
*
exec
.
ExitError
);
ok
{
rr
.
ExitCode
=
exitError
.
ExitCode
()
}
glog
.
Infof
(
"(SSHRunner) Non-zero exit: %v: %v (%s)
\n
%s"
,
rr
.
Command
(),
err
,
elapsed
,
rr
.
Output
())
}
}
return
rr
,
err
return
rr
,
fmt
.
Errorf
(
"%s: %v
\n
stdout:
\n
%s
\n
stderr:
\n
%s"
,
rr
.
Command
(),
err
,
rr
.
Stdout
.
String
(),
rr
.
Stderr
.
String
())
}
}
// Copy copies a file to the remote over SSH.
// Copy copies a file to the remote over SSH.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录