Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
a702ce65
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 搜索 >>
未验证
提交
a702ce65
编写于
6月 24, 2019
作者:
T
Thomas Strömberg
提交者:
GitHub
6月 24, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4562 from kubernetes/demo
Universally redirect stdlog messages to glog
上级
fa54e2ab
31354884
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
21 deletion
+35
-21
cmd/minikube/cmd/start.go
cmd/minikube/cmd/start.go
+1
-1
cmd/minikube/main.go
cmd/minikube/main.go
+34
-0
pkg/minikube/machine/cache_images.go
pkg/minikube/machine/cache_images.go
+0
-20
未找到文件。
cmd/minikube/cmd/start.go
浏览文件 @
a702ce65
...
...
@@ -291,6 +291,7 @@ func showKubectlConnectInfo(kubeconfig *pkgutil.KubeConfigSetup) {
func
selectImageRepository
(
mirrorCountry
string
,
k8sVersion
string
)
(
bool
,
string
,
error
)
{
var
tryCountries
[]
string
var
fallback
string
glog
.
Infof
(
"selecting image repository for country %s ..."
,
mirrorCountry
)
if
mirrorCountry
!=
""
{
localRepos
,
ok
:=
constants
.
ImageRepositories
[
mirrorCountry
]
...
...
@@ -424,7 +425,6 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) {
repository
:=
viper
.
GetString
(
imageRepository
)
mirrorCountry
:=
strings
.
ToLower
(
viper
.
GetString
(
imageMirrorCountry
))
if
strings
.
ToLower
(
repository
)
==
"auto"
||
mirrorCountry
!=
""
{
console
.
OutStyle
(
console
.
Connectivity
,
"checking main repository and mirrors for images"
)
found
,
autoSelectedRepository
,
err
:=
selectImageRepository
(
mirrorCountry
,
k8sVersion
)
if
err
!=
nil
{
exit
.
WithError
(
"Failed to check main repository and mirrors for images for images"
,
err
)
...
...
cmd/minikube/main.go
浏览文件 @
a702ce65
...
...
@@ -17,7 +17,11 @@ limitations under the License.
package
main
import
(
"bytes"
"fmt"
"log"
"os"
"strconv"
"github.com/golang/glog"
"github.com/pkg/profile"
...
...
@@ -32,7 +36,9 @@ import (
const
minikubeEnableProfile
=
"MINIKUBE_ENABLE_PROFILING"
func
main
()
{
captureStdLogMessages
()
defer
glog
.
Flush
()
if
os
.
Getenv
(
minikubeEnableProfile
)
==
"1"
{
defer
profile
.
Start
(
profile
.
TraceProfile
)
.
Stop
()
}
...
...
@@ -44,3 +50,31 @@ func main() {
translate
.
DetermineLocale
()
cmd
.
Execute
()
}
// captureStdLogMessages arranges for messages written to the Go "log" package's to appear in glog
func
captureStdLogMessages
()
{
log
.
SetFlags
(
log
.
Lshortfile
)
log
.
SetOutput
(
logBridge
{})
}
type
logBridge
struct
{}
// Write parses the standard logging line and passes its components to glog
func
(
lb
logBridge
)
Write
(
b
[]
byte
)
(
n
int
,
err
error
)
{
// Split "d.go:23: message" into "d.go", "23", and "message".
parts
:=
bytes
.
SplitN
(
b
,
[]
byte
{
':'
},
3
)
if
len
(
parts
)
!=
3
||
len
(
parts
[
0
])
<
1
||
len
(
parts
[
2
])
<
1
{
glog
.
Errorf
(
"bad log format: %s"
,
b
)
return
}
file
:=
string
(
parts
[
0
])
text
:=
string
(
parts
[
2
][
1
:
])
// skip leading space
line
,
err
:=
strconv
.
Atoi
(
string
(
parts
[
1
]))
if
err
!=
nil
{
text
=
fmt
.
Sprintf
(
"bad line number: %s"
,
b
)
line
=
0
}
glog
.
Infof
(
"stdlog: %s:%d %s"
,
file
,
line
,
text
)
return
len
(
b
),
nil
}
pkg/minikube/machine/cache_images.go
浏览文件 @
a702ce65
...
...
@@ -17,10 +17,7 @@ limitations under the License.
package
machine
import
(
"bytes"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
...
...
@@ -285,23 +282,6 @@ func getDstPath(dst string) (string, error) {
// CacheImage caches an image
func
CacheImage
(
image
,
dst
string
)
error
{
// There are go-containerregistry calls here that result in
// ugly log messages getting printed to stdout. Capture
// stdout instead and writing it to info.
r
,
w
,
err
:=
os
.
Pipe
()
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"opening writing buffer"
)
}
log
.
SetOutput
(
w
)
defer
func
()
{
log
.
SetOutput
(
os
.
Stdout
)
var
buf
bytes
.
Buffer
if
_
,
err
:=
io
.
Copy
(
&
buf
,
r
);
err
!=
nil
{
glog
.
Errorf
(
"output copy failed: %v"
,
err
)
}
glog
.
Infof
(
buf
.
String
())
}()
glog
.
Infof
(
"Attempting to cache image: %s at %s
\n
"
,
image
,
dst
)
if
_
,
err
:=
os
.
Stat
(
dst
);
err
==
nil
{
return
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录