Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
00bf9857
Commit
00bf9857
authored
Jan 25, 2018
by
Di Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm init: skip checking cri socket in preflight checks
parent
e8225f56
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
reset.go
cmd/kubeadm/app/cmd/reset.go
+3
-3
reset_test.go
cmd/kubeadm/app/cmd/reset_test.go
+3
-3
checks.go
cmd/kubeadm/app/preflight/checks.go
+7
-10
No files found.
cmd/kubeadm/app/cmd/reset.go
View file @
00bf9857
...
@@ -184,7 +184,7 @@ func resetWithCrictl(execer utilsexec.Interface, dockerCheck preflight.Checker,
...
@@ -184,7 +184,7 @@ func resetWithCrictl(execer utilsexec.Interface, dockerCheck preflight.Checker,
if
criSocketPath
!=
""
{
if
criSocketPath
!=
""
{
fmt
.
Printf
(
"[reset] Cleaning up running containers using crictl with socket %s
\n
"
,
criSocketPath
)
fmt
.
Printf
(
"[reset] Cleaning up running containers using crictl with socket %s
\n
"
,
criSocketPath
)
listcmd
:=
fmt
.
Sprintf
(
crictlSandboxesParamsFormat
,
crictlPath
,
criSocketPath
)
listcmd
:=
fmt
.
Sprintf
(
crictlSandboxesParamsFormat
,
crictlPath
,
criSocketPath
)
output
,
err
:=
execer
.
Command
(
"sh"
,
"-c"
,
listcmd
)
.
CombinedOutput
()
output
,
err
:=
execer
.
Command
(
listcmd
)
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"[reset] Failed to list running pods using crictl. Trying using docker instead."
)
fmt
.
Println
(
"[reset] Failed to list running pods using crictl. Trying using docker instead."
)
resetWithDocker
(
execer
,
dockerCheck
)
resetWithDocker
(
execer
,
dockerCheck
)
...
@@ -193,13 +193,13 @@ func resetWithCrictl(execer utilsexec.Interface, dockerCheck preflight.Checker,
...
@@ -193,13 +193,13 @@ func resetWithCrictl(execer utilsexec.Interface, dockerCheck preflight.Checker,
sandboxes
:=
strings
.
Split
(
string
(
output
),
" "
)
sandboxes
:=
strings
.
Split
(
string
(
output
),
" "
)
for
_
,
s
:=
range
sandboxes
{
for
_
,
s
:=
range
sandboxes
{
stopcmd
:=
fmt
.
Sprintf
(
crictlStopParamsFormat
,
crictlPath
,
criSocketPath
,
s
)
stopcmd
:=
fmt
.
Sprintf
(
crictlStopParamsFormat
,
crictlPath
,
criSocketPath
,
s
)
if
err
:=
execer
.
Command
(
"sh"
,
"-c"
,
stopcmd
)
.
Run
();
err
!=
nil
{
if
err
:=
execer
.
Command
(
stopcmd
)
.
Run
();
err
!=
nil
{
fmt
.
Println
(
"[reset] Failed to stop the running containers using crictl. Trying using docker instead."
)
fmt
.
Println
(
"[reset] Failed to stop the running containers using crictl. Trying using docker instead."
)
resetWithDocker
(
execer
,
dockerCheck
)
resetWithDocker
(
execer
,
dockerCheck
)
return
return
}
}
removecmd
:=
fmt
.
Sprintf
(
crictlRemoveParamsFormat
,
crictlPath
,
criSocketPath
,
s
)
removecmd
:=
fmt
.
Sprintf
(
crictlRemoveParamsFormat
,
crictlPath
,
criSocketPath
,
s
)
if
err
:=
execer
.
Command
(
"sh"
,
"-c"
,
removecmd
)
.
Run
();
err
!=
nil
{
if
err
:=
execer
.
Command
(
removecmd
)
.
Run
();
err
!=
nil
{
fmt
.
Println
(
"[reset] Failed to remove the running containers using crictl. Trying using docker instead."
)
fmt
.
Println
(
"[reset] Failed to remove the running containers using crictl. Trying using docker instead."
)
resetWithDocker
(
execer
,
dockerCheck
)
resetWithDocker
(
execer
,
dockerCheck
)
return
return
...
...
cmd/kubeadm/app/cmd/reset_test.go
View file @
00bf9857
...
@@ -278,10 +278,10 @@ func TestResetWithCrictl(t *testing.T) {
...
@@ -278,10 +278,10 @@ func TestResetWithCrictl(t *testing.T) {
if
fcmd
.
RunCalls
!=
3
{
if
fcmd
.
RunCalls
!=
3
{
t
.
Errorf
(
"expected 3 calls to Run, got %d"
,
fcmd
.
RunCalls
)
t
.
Errorf
(
"expected 3 calls to Run, got %d"
,
fcmd
.
RunCalls
)
}
}
if
!
strings
.
Contains
(
fcmd
.
RunLog
[
1
][
2
],
"crictl"
)
{
if
!
strings
.
Contains
(
fcmd
.
RunLog
[
1
][
0
],
"crictl"
)
{
t
.
Errorf
(
"expected a call to crictl, got %v"
,
fcmd
.
RunLog
[
0
])
t
.
Errorf
(
"expected a call to crictl, got %v"
,
fcmd
.
RunLog
[
0
])
}
}
if
!
strings
.
Contains
(
fcmd
.
RunLog
[
2
][
2
],
"crictl"
)
{
if
!
strings
.
Contains
(
fcmd
.
RunLog
[
2
][
0
],
"crictl"
)
{
t
.
Errorf
(
"expected a call to crictl, got %v"
,
fcmd
.
RunLog
[
0
])
t
.
Errorf
(
"expected a call to crictl, got %v"
,
fcmd
.
RunLog
[
0
])
}
}
...
@@ -330,7 +330,7 @@ func TestReset(t *testing.T) {
...
@@ -330,7 +330,7 @@ func TestReset(t *testing.T) {
if
fcmd
.
RunCalls
!=
2
{
if
fcmd
.
RunCalls
!=
2
{
t
.
Errorf
(
"expected 2 call to Run, got %d"
,
fcmd
.
RunCalls
)
t
.
Errorf
(
"expected 2 call to Run, got %d"
,
fcmd
.
RunCalls
)
}
}
if
!
strings
.
Contains
(
fcmd
.
RunLog
[
0
][
2
],
"crictl"
)
{
if
!
strings
.
Contains
(
fcmd
.
RunLog
[
0
][
0
],
"crictl"
)
{
t
.
Errorf
(
"expected a call to crictl, got %v"
,
fcmd
.
RunLog
[
0
])
t
.
Errorf
(
"expected a call to crictl, got %v"
,
fcmd
.
RunLog
[
0
])
}
}
...
...
cmd/kubeadm/app/preflight/checks.go
View file @
00bf9857
...
@@ -99,7 +99,12 @@ func (CRICheck) Name() string {
...
@@ -99,7 +99,12 @@ func (CRICheck) Name() string {
// Check validates the container runtime through the CRI.
// Check validates the container runtime through the CRI.
func
(
criCheck
CRICheck
)
Check
()
(
warnings
,
errors
[]
error
)
{
func
(
criCheck
CRICheck
)
Check
()
(
warnings
,
errors
[]
error
)
{
if
err
:=
criCheck
.
exec
.
Command
(
"sh"
,
"-c"
,
fmt
.
Sprintf
(
"crictl -r %s info"
,
criCheck
.
socket
))
.
Run
();
err
!=
nil
{
crictlPath
,
err
:=
criCheck
.
exec
.
LookPath
(
"crictl"
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"unable to find command crictl: %s"
,
err
))
return
warnings
,
errors
}
if
err
:=
criCheck
.
exec
.
Command
(
fmt
.
Sprintf
(
"%s -r %s info"
,
crictlPath
,
criCheck
.
socket
))
.
Run
();
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"unable to check if the container runtime at %q is running: %s"
,
criCheck
.
socket
,
err
))
errors
=
append
(
errors
,
fmt
.
Errorf
(
"unable to check if the container runtime at %q is running: %s"
,
criCheck
.
socket
,
err
))
return
warnings
,
errors
return
warnings
,
errors
}
}
...
@@ -859,8 +864,6 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
...
@@ -859,8 +864,6 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
exec
:
execer
,
exec
:
execer
,
suggestion
:
fmt
.
Sprintf
(
"go get %v"
,
kubeadmconstants
.
CRICtlPackage
),
suggestion
:
fmt
.
Sprintf
(
"go get %v"
,
kubeadmconstants
.
CRICtlPackage
),
}
}
warns
,
_
:=
criCtlChecker
.
Check
()
useCRI
:=
len
(
warns
)
==
0
manifestsDir
:=
filepath
.
Join
(
kubeadmconstants
.
KubernetesDir
,
kubeadmconstants
.
ManifestsSubDirName
)
manifestsDir
:=
filepath
.
Join
(
kubeadmconstants
.
KubernetesDir
,
kubeadmconstants
.
ManifestsSubDirName
)
...
@@ -871,6 +874,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
...
@@ -871,6 +874,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
HostnameCheck
{
nodeName
:
cfg
.
NodeName
},
HostnameCheck
{
nodeName
:
cfg
.
NodeName
},
KubeletVersionCheck
{
KubernetesVersion
:
cfg
.
KubernetesVersion
},
KubeletVersionCheck
{
KubernetesVersion
:
cfg
.
KubernetesVersion
},
ServiceCheck
{
Service
:
"kubelet"
,
CheckIfActive
:
false
},
ServiceCheck
{
Service
:
"kubelet"
,
CheckIfActive
:
false
},
ServiceCheck
{
Service
:
"docker"
,
CheckIfActive
:
true
},
// assume docker
FirewalldCheck
{
ports
:
[]
int
{
int
(
cfg
.
API
.
BindPort
),
10250
}},
FirewalldCheck
{
ports
:
[]
int
{
int
(
cfg
.
API
.
BindPort
),
10250
}},
PortOpenCheck
{
port
:
int
(
cfg
.
API
.
BindPort
)},
PortOpenCheck
{
port
:
int
(
cfg
.
API
.
BindPort
)},
PortOpenCheck
{
port
:
10250
},
PortOpenCheck
{
port
:
10250
},
...
@@ -902,13 +906,6 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
...
@@ -902,13 +906,6 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.MasterConfi
HTTPProxyCIDRCheck
{
Proto
:
"https"
,
CIDR
:
cfg
.
Networking
.
PodSubnet
},
HTTPProxyCIDRCheck
{
Proto
:
"https"
,
CIDR
:
cfg
.
Networking
.
PodSubnet
},
}
}
if
useCRI
{
checks
=
append
(
checks
,
CRICheck
{
socket
:
criSocket
,
exec
:
execer
})
}
else
{
// assume docker
checks
=
append
(
checks
,
ServiceCheck
{
Service
:
"docker"
,
CheckIfActive
:
true
})
}
if
len
(
cfg
.
Etcd
.
Endpoints
)
==
0
{
if
len
(
cfg
.
Etcd
.
Endpoints
)
==
0
{
// Only do etcd related checks when no external endpoints were specified
// Only do etcd related checks when no external endpoints were specified
checks
=
append
(
checks
,
checks
=
append
(
checks
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment