Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
afab7c87
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 搜索 >>
未验证
提交
afab7c87
编写于
5月 11, 2020
作者:
M
Medya Ghazizadeh
提交者:
GitHub
5月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7959 from afbjorklund/podman-prompt
Use noninteractive sudo when running podman
上级
07d5472f
3fa4b916
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
11 deletion
+28
-11
cmd/minikube/cmd/delete.go
cmd/minikube/cmd/delete.go
+26
-9
pkg/drivers/kic/oci/cli_runner.go
pkg/drivers/kic/oci/cli_runner.go
+1
-1
pkg/minikube/registry/drvs/podman/podman.go
pkg/minikube/registry/drvs/podman/podman.go
+1
-1
未找到文件。
cmd/minikube/cmd/delete.go
浏览文件 @
afab7c87
...
...
@@ -90,26 +90,31 @@ func init() {
}
// shotgun cleanup to delete orphaned docker container data
func
deleteContainersAndVolumes
()
{
if
_
,
err
:=
exec
.
LookPath
(
oci
.
Docker
);
err
!=
nil
{
glog
.
Infof
(
"skipping deleteContainersAndVolumes for %s: %v"
,
oci
.
Docker
,
err
)
func
deleteContainersAndVolumes
(
ociBin
string
)
{
if
_
,
err
:=
exec
.
LookPath
(
oci
Bin
);
err
!=
nil
{
glog
.
Infof
(
"skipping deleteContainersAndVolumes for %s: %v"
,
oci
Bin
,
err
)
return
}
glog
.
Infof
(
"deleting containers and volumes ..."
)
delLabel
:=
fmt
.
Sprintf
(
"%s=%s"
,
oci
.
CreatedByLabelKey
,
"true"
)
errs
:=
oci
.
DeleteContainersByLabel
(
oci
.
Docker
,
delLabel
)
errs
:=
oci
.
DeleteContainersByLabel
(
oci
Bin
,
delLabel
)
if
len
(
errs
)
>
0
{
// it will error if there is no container to delete
glog
.
Infof
(
"error delete containers by label %q (might be okay): %+v"
,
delLabel
,
errs
)
}
errs
=
oci
.
DeleteAllVolumesByLabel
(
oci
.
Docker
,
delLabel
)
errs
=
oci
.
DeleteAllVolumesByLabel
(
oci
Bin
,
delLabel
)
if
len
(
errs
)
>
0
{
// it will not error if there is nothing to delete
glog
.
Warningf
(
"error delete volumes by label %q (might be okay): %+v"
,
delLabel
,
errs
)
}
errs
=
oci
.
PruneAllVolumesByLabel
(
oci
.
Docker
,
delLabel
)
if
ociBin
==
oci
.
Podman
{
// podman prune does not support --filter
return
}
errs
=
oci
.
PruneAllVolumesByLabel
(
ociBin
,
delLabel
)
if
len
(
errs
)
>
0
{
// it will not error if there is nothing to delete
glog
.
Warningf
(
"error pruning volumes by label %q (might be okay): %+v"
,
delLabel
,
errs
)
}
...
...
@@ -137,7 +142,8 @@ func runDelete(cmd *cobra.Command, args []string) {
}
if
deleteAll
{
deleteContainersAndVolumes
()
deleteContainersAndVolumes
(
oci
.
Docker
)
deleteContainersAndVolumes
(
oci
.
Podman
)
errs
:=
DeleteProfiles
(
profilesToDelete
)
if
len
(
errs
)
>
0
{
...
...
@@ -167,6 +173,7 @@ func runDelete(cmd *cobra.Command, args []string) {
if
orphan
{
// TODO: generalize for non-KIC drivers: #8040
deletePossibleKicLeftOver
(
cname
,
driver
.
Docker
)
deletePossibleKicLeftOver
(
cname
,
driver
.
Podman
)
}
}
...
...
@@ -209,8 +216,6 @@ func DeleteProfiles(profiles []*config.Profile) []error {
// TODO: remove and/or move to delete package: #8040
func
deletePossibleKicLeftOver
(
cname
string
,
driverName
string
)
{
glog
.
Infof
(
"deleting possible KIC leftovers for %s (driver=%s) ..."
,
cname
,
driverName
)
bin
:=
""
switch
driverName
{
case
driver
.
Docker
:
...
...
@@ -221,6 +226,13 @@ func deletePossibleKicLeftOver(cname string, driverName string) {
return
}
if
_
,
err
:=
exec
.
LookPath
(
bin
);
err
!=
nil
{
glog
.
Infof
(
"skipping deletePossibleKicLeftOver for %s: %v"
,
bin
,
err
)
return
}
glog
.
Infof
(
"deleting possible KIC leftovers for %s (driver=%s) ..."
,
cname
,
driverName
)
delLabel
:=
fmt
.
Sprintf
(
"%s=%s"
,
oci
.
ProfileLabelKey
,
cname
)
cs
,
err
:=
oci
.
ListContainersByLabel
(
bin
,
delLabel
)
if
err
==
nil
&&
len
(
cs
)
>
0
{
...
...
@@ -239,6 +251,11 @@ func deletePossibleKicLeftOver(cname string, driverName string) {
glog
.
Warningf
(
"error deleting volumes (might be okay).
\n
To see the list of volumes run: 'docker volume ls'
\n
:%v"
,
errs
)
}
if
bin
==
oci
.
Podman
{
// podman prune does not support --filter
return
}
errs
=
oci
.
PruneAllVolumesByLabel
(
bin
,
delLabel
)
if
len
(
errs
)
>
0
{
// it will not error if there is nothing to delete
glog
.
Warningf
(
"error pruning volume (might be okay):
\n
%v"
,
errs
)
...
...
pkg/drivers/kic/oci/cli_runner.go
浏览文件 @
afab7c87
...
...
@@ -67,7 +67,7 @@ func (rr RunResult) Output() string {
// PrefixCmd adds any needed prefix (such as sudo) to the command
func
PrefixCmd
(
cmd
*
exec
.
Cmd
)
*
exec
.
Cmd
{
if
cmd
.
Args
[
0
]
==
Podman
&&
runtime
.
GOOS
==
"linux"
{
// want sudo when not running podman-remote
cmdWithSudo
:=
exec
.
Command
(
"sudo"
,
cmd
.
Args
...
)
cmdWithSudo
:=
exec
.
Command
(
"sudo"
,
append
([]
string
{
"-n"
},
cmd
.
Args
...
)
...
)
cmdWithSudo
.
Env
=
cmd
.
Env
cmdWithSudo
.
Dir
=
cmd
.
Dir
cmdWithSudo
.
Stdin
=
cmd
.
Stdin
...
...
pkg/minikube/registry/drvs/podman/podman.go
浏览文件 @
afab7c87
...
...
@@ -90,7 +90,7 @@ func status() registry.State {
cmd
:=
exec
.
CommandContext
(
ctx
,
oci
.
Podman
,
"version"
,
"--format"
,
"{{.Server.Version}}"
)
// Run with sudo on linux (local), otherwise podman-remote (as podman)
if
runtime
.
GOOS
==
"linux"
{
cmd
=
exec
.
CommandContext
(
ctx
,
"sudo"
,
"-n"
,
oci
.
Podman
,
"version"
,
"--format"
,
"{{.Version}}"
)
cmd
=
exec
.
CommandContext
(
ctx
,
"sudo"
,
"-
k"
,
"-
n"
,
oci
.
Podman
,
"version"
,
"--format"
,
"{{.Version}}"
)
cmd
.
Env
=
append
(
os
.
Environ
(),
"LANG=C"
,
"LC_ALL=C"
)
// sudo is localized
}
o
,
err
:=
cmd
.
Output
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录