Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
16c20771
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 搜索 >>
未验证
提交
16c20771
编写于
4月 20, 2020
作者:
M
Medya Gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add helpers and unit test
上级
366dc8d1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
68 addition
and
18 deletion
+68
-18
pkg/minikube/cruntime/containerd _test.go
pkg/minikube/cruntime/containerd _test.go
+40
-0
pkg/minikube/cruntime/containerd.go
pkg/minikube/cruntime/containerd.go
+13
-5
pkg/minikube/cruntime/cruntime.go
pkg/minikube/cruntime/cruntime.go
+11
-0
pkg/minikube/machine/cache_images.go
pkg/minikube/machine/cache_images.go
+4
-13
未找到文件。
pkg/minikube/cruntime/containerd _test.go
0 → 100644
浏览文件 @
16c20771
/*
Copyright 2020 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
cruntime
import
(
"testing"
)
func
TestAddRepoTagToImageName
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
imgName
string
want
string
}{
{
"kubernetesui/dashboard:v2.0.0-rc6"
,
"docker.io/kubernetesui/dashboard:v2.0.0-rc6"
},
{
"kubernetesui/metrics-scraper:v1.0.2"
,
"docker.io/kubernetesui/metrics-scraper:v1.0.2"
},
{
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1"
,
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1"
},
}
for
_
,
tc
:=
range
tests
{
t
.
Run
(
tc
.
imgName
,
func
(
t
*
testing
.
T
)
{
got
:=
addRepoTagToImageName
(
tc
.
imgName
)
if
got
!=
tc
.
want
{
t
.
Errorf
(
"expected image name to be: %q but got %q"
,
tc
.
want
,
got
)
}
})
}
}
pkg/minikube/cruntime/containerd.go
浏览文件 @
16c20771
...
...
@@ -398,11 +398,7 @@ func ContainerdImagesPreloaded(runner command.Runner, images []string) bool {
found
:=
false
for
_
,
ji
:=
range
jsonImages
.
Images
{
for
_
,
rt
:=
range
ji
.
RepoTags
{
// in crictl docker.io is appened to images without repo organization
// for example "kubernetesui/dashboard:v2.0.0-rc6 will show up as "docker.io/kubernetesui/dashboard:v2.0.0-rc6"
if
!
strings
.
Contains
(
i
,
".io/"
)
{
i
=
"docker.io/"
+
i
}
i
=
addRepoTagToImageName
(
i
)
if
i
==
rt
{
found
=
true
break
...
...
@@ -421,3 +417,15 @@ func ContainerdImagesPreloaded(runner command.Runner, images []string) bool {
glog
.
Infof
(
"all images are preloaded for containerd runtime."
)
return
true
}
// addRepoTagToImageName makes sure the image name has a repo tag in it.
// in crictl images list have the repo tag prepended to them
// for example "kubernetesui/dashboard:v2.0.0 will show up as "docker.io/kubernetesui/dashboard:v2.0.0"
// warning this is only meant for kuberentes images where we know the GCR addreses have .io in them
// not mean to be used for public images
func
addRepoTagToImageName
(
imgName
string
)
string
{
if
!
strings
.
Contains
(
imgName
,
".io/"
)
{
return
"docker.io/"
+
imgName
}
// else it already has repo name dont add anything
return
imgName
}
pkg/minikube/cruntime/cruntime.go
浏览文件 @
16c20771
...
...
@@ -220,3 +220,14 @@ func enableIPForwarding(cr CommandRunner) error {
}
return
nil
}
// ImagesPreloaded returns true if all images have been preloaded
func
ImagesPreloaded
(
containerRuntime
string
,
runner
command
.
Runner
,
images
[]
string
)
bool
{
if
containerRuntime
==
"docker"
{
return
DockerImagesPreloaded
(
runner
,
images
)
}
if
containerRuntime
==
"containerd"
{
return
ContainerdImagesPreloaded
(
runner
,
images
)
}
return
false
}
pkg/minikube/machine/cache_images.go
浏览文件 @
16c20771
...
...
@@ -64,19 +64,10 @@ func CacheImagesForBootstrapper(imageRepository string, version string, clusterB
// LoadImages loads previously cached images into the container runtime
func
LoadImages
(
cc
*
config
.
ClusterConfig
,
runner
command
.
Runner
,
images
[]
string
,
cacheDir
string
)
error
{
if
cc
.
KubernetesConfig
.
ContainerRuntime
==
"docker"
{
// Skip loading images if images already exist
if
cruntime
.
DockerImagesPreloaded
(
runner
,
images
)
{
glog
.
Infof
(
"Images are preloaded, skipping loading"
)
return
nil
}
}
if
cc
.
KubernetesConfig
.
ContainerRuntime
==
"containerd"
{
// Skip loading images if images already exist
if
cruntime
.
ContainerdImagesPreloaded
(
runner
,
images
)
{
glog
.
Infof
(
"Images are preloaded, skipping loading"
)
return
nil
}
// Skip loading images if images already exist
if
cruntime
.
ImagesPreloaded
(
cc
.
KubernetesConfig
.
ContainerRuntime
,
runner
,
images
)
{
glog
.
Infof
(
"Images are preloaded, skipping loading"
)
return
nil
}
glog
.
Infof
(
"LoadImages start: %s"
,
images
)
start
:=
time
.
Now
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录