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
c903aa76
Commit
c903aa76
authored
May 07, 2015
by
Robert Bailey
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7932 from fabioy/check-good-nodes.fix
Check node status as part of validate-cluster.sh.
parents
589154a5
89b3ffa5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
validate-cluster.sh
cluster/validate-cluster.sh
+17
-7
No files found.
cluster/validate-cluster.sh
View file @
c903aa76
...
@@ -30,13 +30,23 @@ trap 'rm -rf "${MINIONS_FILE}"' EXIT
...
@@ -30,13 +30,23 @@ trap 'rm -rf "${MINIONS_FILE}"' EXIT
# Make several attempts to deal with slow cluster birth.
# Make several attempts to deal with slow cluster birth.
attempt
=
0
attempt
=
0
while
true
;
do
while
true
;
do
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
get nodes
-o
template
-t
$'{{range.items}}{{.metadata.name}}
\n
{{end}}'
--api-version
=
v1beta3
>
"
${
MINIONS_FILE
}
"
# The "kubectl get nodes" output is three columns like this:
found
=
$(
grep
-c
.
"
${
MINIONS_FILE
}
"
)
||
true
#
if
[[
${
found
}
==
"
${
NUM_MINIONS
}
"
]]
;
then
# NAME LABELS STATUS
# kubernetes-minion-03nb <none> Ready
#
# Echo the output, strip the first line, then gather 2 counts:
# - Total number of nodes.
# - Number of "ready" nodes.
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
get nodes
>
"
${
MINIONS_FILE
}
"
||
true
found
=
$(
cat
"
${
MINIONS_FILE
}
"
|
sed
'1d'
|
grep
-c
.
)
||
true
ready
=
$(
cat
"
${
MINIONS_FILE
}
"
|
sed
'1d'
|
awk
'{print $NF}'
|
grep
-c
'^Ready'
)
||
true
if
((
${
found
}
==
"
${
NUM_MINIONS
}
"
))
&&
((
${
ready
}
==
"
${
NUM_MINIONS
}
"
))
;
then
break
break
else
else
if
((
attempt
>
5
))
;
then
if
((
attempt
>
5
))
;
then
echo
-e
"
${
color_red
}
Detected
${
found
}
nodes out of
${
NUM_MINIONS
}
. Your cluster may not be working.
${
color_norm
}
"
echo
-e
"
${
color_red
}
Detected
${
ready
}
ready nodes, found
${
found
}
nodes out of expected
${
NUM_MINIONS
}
. Your cluster may not be working.
${
color_norm
}
"
cat
-n
"
${
MINIONS_FILE
}
"
cat
-n
"
${
MINIONS_FILE
}
"
exit
2
exit
2
fi
fi
...
@@ -57,13 +67,13 @@ while true; do
...
@@ -57,13 +67,13 @@ while true; do
# controller-manager Healthy ok nil
# controller-manager Healthy ok nil
#
#
# Parse the output to capture the value of the second column("HEALTH"), then use grep to
# Parse the output to capture the value of the second column("HEALTH"), then use grep to
# count the number of times it doesn't match "success".
# count the number of times it doesn't match "Healthy".
# Because of the header, the actual unsuccessful count is 1 minus the count.
non_success_count
=
$(
echo
"
${
kubectl_output
}
"
|
\
non_success_count
=
$(
echo
"
${
kubectl_output
}
"
|
\
sed
'1d'
|
sed
-n
's/^[[:alnum:][:punct:]]/&/p'
|
\
sed
-n
's/^[[:alnum:][:punct:]]/&/p'
|
\
grep
--invert-match
-c
'^[[:alnum:][:punct:]]\{1,\}[[:space:]]\{1,\}Healthy'
)
||
true
grep
--invert-match
-c
'^[[:alnum:][:punct:]]\{1,\}[[:space:]]\{1,\}Healthy'
)
||
true
if
((
non_success_count
>
1
))
;
then
if
((
non_success_count
>
0
))
;
then
if
((
attempt < 5
))
;
then
if
((
attempt < 5
))
;
then
echo
-e
"
${
color_yellow
}
Cluster not working yet.
${
color_norm
}
"
echo
-e
"
${
color_yellow
}
Cluster not working yet.
${
color_norm
}
"
attempt
=
$((
attempt+1
))
attempt
=
$((
attempt+1
))
...
...
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