Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
5569817c
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,发现更多精彩内容 >>
提交
5569817c
编写于
11月 10, 2020
作者:
P
Priya Wadhwa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address code review comments
上级
291e5b69
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
29 deletion
+39
-29
cmd/minikube/cmd/stop.go
cmd/minikube/cmd/stop.go
+1
-4
pkg/minikube/schedule/daemonize_unix.go
pkg/minikube/schedule/daemonize_unix.go
+33
-22
pkg/minikube/schedule/daemonize_windows.go
pkg/minikube/schedule/daemonize_windows.go
+5
-3
未找到文件。
cmd/minikube/cmd/stop.go
浏览文件 @
5569817c
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
cmd
package
cmd
import
(
import
(
"log"
"os"
"os"
"runtime"
"runtime"
"time"
"time"
...
@@ -97,9 +96,7 @@ func runStop(cmd *cobra.Command, args []string) {
...
@@ -97,9 +96,7 @@ func runStop(cmd *cobra.Command, args []string) {
}
}
// Kill any existing scheduled stops
// Kill any existing scheduled stops
if
err
:=
schedule
.
KillExisting
(
profilesToStop
);
err
!=
nil
{
schedule
.
KillExisting
(
profilesToStop
)
log
.
Printf
(
"error killing existing scheduled stops: %v"
,
err
)
}
if
scheduledStopDuration
!=
0
{
if
scheduledStopDuration
!=
0
{
if
runtime
.
GOOS
==
"windows"
{
if
runtime
.
GOOS
==
"windows"
{
...
...
pkg/minikube/schedule/daemonize_unix.go
浏览文件 @
5569817c
...
@@ -31,30 +31,41 @@ import (
...
@@ -31,30 +31,41 @@ import (
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/localpath"
)
)
// KillExisting kills existing scheduled stops
// KillExisting kills existing scheduled stops by looking up the PID
func
KillExisting
(
profiles
[]
string
)
error
{
// of the scheduled stop from the PID file saved for the profile and killing the process
func
KillExisting
(
profiles
[]
string
)
{
for
_
,
profile
:=
range
profiles
{
for
_
,
profile
:=
range
profiles
{
file
:=
localpath
.
PID
(
profile
)
if
err
:=
killPIDForProfile
(
profile
);
err
!=
nil
{
f
,
err
:=
ioutil
.
ReadFile
(
file
)
klog
.
Errorf
(
"error killng PID for profile %s: %v"
,
profile
,
err
)
if
os
.
IsNotExist
(
err
)
{
return
nil
}
}
defer
os
.
Remove
(
file
)
}
if
err
!=
nil
{
}
return
errors
.
Wrapf
(
err
,
"reading %s"
,
file
)
}
func
killPIDForProfile
(
profile
string
)
error
{
pid
,
err
:=
strconv
.
Atoi
(
string
(
f
))
file
:=
localpath
.
PID
(
profile
)
if
err
!=
nil
{
f
,
err
:=
ioutil
.
ReadFile
(
file
)
return
errors
.
Wrapf
(
err
,
"converting %v to int"
,
string
(
f
))
if
os
.
IsNotExist
(
err
)
{
}
return
nil
p
,
err
:=
os
.
FindProcess
(
pid
)
}
if
err
!=
nil
{
defer
func
()
{
return
errors
.
Wrap
(
err
,
"finding process"
)
if
err
:=
os
.
Remove
(
file
);
err
!=
nil
{
}
klog
.
Errorf
(
"error deleting %s: %v, you may have to delete in manually"
,
file
,
err
)
klog
.
Infof
(
"killing process %v as it is an old scheduled stop"
,
pid
)
if
err
:=
p
.
Kill
();
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"killing %v"
,
pid
)
}
}
}()
if
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"reading %s"
,
file
)
}
pid
,
err
:=
strconv
.
Atoi
(
string
(
f
))
if
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"converting %s to int"
,
f
)
}
p
,
err
:=
os
.
FindProcess
(
pid
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"finding process"
)
}
klog
.
Infof
(
"killing process %v as it is an old scheduled stop"
,
pid
)
if
err
:=
p
.
Kill
();
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"killing %v"
,
pid
)
}
}
return
nil
return
nil
}
}
...
@@ -72,7 +83,7 @@ func daemonize(profiles []string, duration time.Duration) error {
...
@@ -72,7 +83,7 @@ func daemonize(profiles []string, duration time.Duration) error {
func
savePIDs
(
pid
int
,
profiles
[]
string
)
error
{
func
savePIDs
(
pid
int
,
profiles
[]
string
)
error
{
for
_
,
p
:=
range
profiles
{
for
_
,
p
:=
range
profiles
{
file
:=
localpath
.
PID
(
p
)
file
:=
localpath
.
PID
(
p
)
if
err
:=
ioutil
.
WriteFile
(
file
,
[]
byte
(
fmt
.
Sprintf
(
"%v"
,
pid
)),
06
44
);
err
!=
nil
{
if
err
:=
ioutil
.
WriteFile
(
file
,
[]
byte
(
fmt
.
Sprintf
(
"%v"
,
pid
)),
06
00
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/minikube/schedule/daemonize_windows.go
浏览文件 @
5569817c
...
@@ -21,11 +21,13 @@ package schedule
...
@@ -21,11 +21,13 @@ package schedule
import
(
import
(
"fmt"
"fmt"
"time"
"time"
"k8s.io/klog/v2"
)
)
// KillExisting
kills
existing scheduled stops
// KillExisting
will kill
existing scheduled stops
func
KillExisting
(
profiles
[]
string
)
error
{
func
KillExisting
(
profiles
[]
string
)
{
return
fmt
.
Errorf
(
"not yet implemented for windows"
)
klog
.
Errorf
(
"not yet implemented for windows"
)
}
}
func
daemonize
(
profiles
[]
string
,
duration
time
.
Duration
)
error
{
func
daemonize
(
profiles
[]
string
,
duration
time
.
Duration
)
error
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录