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
68113cac
Unverified
Commit
68113cac
authored
Feb 02, 2017
by
Paulo Pires
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: fix reset error logging.
parent
0477100f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
reset.go
cmd/kubeadm/app/cmd/reset.go
+9
-8
No files found.
cmd/kubeadm/app/cmd/reset.go
View file @
68113cac
...
@@ -144,7 +144,6 @@ func (r *Reset) Run(out io.Writer) error {
...
@@ -144,7 +144,6 @@ func (r *Reset) Run(out io.Writer) error {
}
}
func
drainAndRemoveNode
(
removeNode
bool
)
error
{
func
drainAndRemoveNode
(
removeNode
bool
)
error
{
hostname
,
err
:=
os
.
Hostname
()
hostname
,
err
:=
os
.
Hostname
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to detect node hostname"
)
return
fmt
.
Errorf
(
"failed to detect node hostname"
)
...
@@ -156,24 +155,26 @@ func drainAndRemoveNode(removeNode bool) error {
...
@@ -156,24 +155,26 @@ func drainAndRemoveNode(removeNode bool) error {
getNodesCmd
:=
fmt
.
Sprintf
(
"kubectl --kubeconfig %s get nodes | grep %s"
,
kubeConfigPath
,
hostname
)
getNodesCmd
:=
fmt
.
Sprintf
(
"kubectl --kubeconfig %s get nodes | grep %s"
,
kubeConfigPath
,
hostname
)
output
,
err
:=
exec
.
Command
(
"sh"
,
"-c"
,
getNodesCmd
)
.
Output
()
output
,
err
:=
exec
.
Command
(
"sh"
,
"-c"
,
getNodesCmd
)
.
Output
()
if
err
!=
nil
||
len
(
output
)
==
0
{
if
err
!=
nil
{
// kubeadm shouldn't drain and/or remove the node when it doesn't exist anymore
// kubeadm shouldn't drain and/or remove the node when it doesn't exist anymore
return
nil
return
fmt
.
Errorf
(
"failed to list nodes: %v"
,
err
)
}
if
len
(
output
)
==
0
{
return
fmt
.
Errorf
(
"list nodes request returned zero entries"
)
}
}
fmt
.
Printf
(
"[reset] Draining node: %q
\n
"
,
hostname
)
fmt
.
Printf
(
"[reset] Draining node: %q
\n
"
,
hostname
)
output
,
err
=
exec
.
Command
(
"kubectl"
,
"--kubeconfig"
,
kubeConfigPath
,
"drain"
,
hostname
,
"--delete-local-data"
,
"--force"
,
"--ignore-daemonsets"
)
.
Output
()
_
,
err
=
exec
.
Command
(
"kubectl"
,
"--kubeconfig"
,
kubeConfigPath
,
"drain"
,
hostname
,
"--delete-local-data"
,
"--force"
,
"--ignore-daemonsets"
)
.
Output
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to drain node %q
[%s]"
,
hostname
,
output
)
return
fmt
.
Errorf
(
"failed to drain node %q
: %v"
,
hostname
,
err
)
}
}
if
removeNode
{
if
removeNode
{
fmt
.
Printf
(
"[reset] Removing node: %q
\n
"
,
hostname
)
fmt
.
Printf
(
"[reset] Removing node: %q
\n
"
,
hostname
)
_
,
err
=
exec
.
Command
(
"kubectl"
,
"--kubeconfig"
,
kubeConfigPath
,
"delete"
,
"node"
,
hostname
)
.
Output
()
output
,
err
=
exec
.
Command
(
"kubectl"
,
"--kubeconfig"
,
kubeConfigPath
,
"delete"
,
"node"
,
hostname
)
.
Output
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to remove node %q
[%s]"
,
hostname
,
output
)
return
fmt
.
Errorf
(
"failed to remove node %q
: %v"
,
hostname
,
err
)
}
}
}
}
...
...
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