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
43d217f9
Commit
43d217f9
authored
Jun 15, 2018
by
wojtekt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Periodically fetch logexported nodes instead of sleeping
parent
0f9dfca8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
10 deletions
+36
-10
log-dump.sh
cluster/log-dump/log-dump.sh
+36
-10
No files found.
cluster/log-dump/log-dump.sh
View file @
43d217f9
...
@@ -281,6 +281,24 @@ function dump_nodes() {
...
@@ -281,6 +281,24 @@ function dump_nodes() {
fi
fi
}
}
# Collect names of nodes which didn't run logexporter successfully.
# Note: This step is O(#nodes^2) as we check if each node is present in the list of succeeded nodes.
# Making it linear would add code complexity without much benefit (as it just takes ~1s for 5k nodes).
# Assumes:
# NODE_NAMES
# Sets:
# NON_LOGEXPORTED_NODES
function
find_non_logexported_nodes
()
{
succeeded_nodes
=
$(
gsutil
ls
${
gcs_artifacts_dir
}
/logexported-nodes-registry
)
||
return
1
echo
"Successfully listed marker files for successful nodes"
NON_LOGEXPORTED_NODES
=()
for
node
in
"
${
NODE_NAMES
[@]
}
"
;
do
if
[[
!
"
${
succeeded_nodes
}
"
=
~
"
${
node
}
"
]]
;
then
NON_LOGEXPORTED_NODES+
=(
"
${
node
}
"
)
fi
done
}
function
dump_nodes_with_logexporter
()
{
function
dump_nodes_with_logexporter
()
{
echo
"Detecting nodes in the cluster"
echo
"Detecting nodes in the cluster"
detect-node-names &> /dev/null
detect-node-names &> /dev/null
...
@@ -312,14 +330,27 @@ function dump_nodes_with_logexporter() {
...
@@ -312,14 +330,27 @@ function dump_nodes_with_logexporter() {
return
return
fi
fi
# Give some time for the pods to finish uploading logs.
# Periodically fetch list of already logexported nodes to verify
sleep
"
${
logexport_sleep_seconds
}
"
# if we aren't already done.
start
=
"
$(
date
+%s
)
"
while
true
;
do
now
=
"
$(
date
+%s
)
"
if
[[
$((
now
-
start
))
-gt
${
logexport_sleep_seconds
}
]]
;
then
echo
"Waiting for all nodes to be logexported timed out."
break
fi
if
find_non_logexported_nodes
;
then
if
[[
-z
"
${
NON_LOGEXPORTED_NODES
:-}
"
]]
;
then
break
fi
fi
sleep
15
done
# List registry of marker files (of nodes whose logexporter succeeded) from GCS.
# List registry of marker files (of nodes whose logexporter succeeded) from GCS.
local
nodes_succeeded
local
nodes_succeeded
for
retry
in
{
1..10
}
;
do
for
retry
in
{
1..10
}
;
do
if
nodes_succeeded
=
$(
gsutil
ls
${
gcs_artifacts_dir
}
/logexported-nodes-registry
)
;
then
if
find_non_logexported_nodes
;
then
echo
"Successfully listed marker files for successful nodes"
break
break
else
else
echo
"Attempt
${
retry
}
failed to list marker files for succeessful nodes"
echo
"Attempt
${
retry
}
failed to list marker files for succeessful nodes"
...
@@ -333,15 +364,10 @@ function dump_nodes_with_logexporter() {
...
@@ -333,15 +364,10 @@ function dump_nodes_with_logexporter() {
fi
fi
done
done
# Collect names of nodes which didn't run logexporter successfully.
# Note: This step is O(#nodes^2) as we check if each node is present in the list of succeeded nodes.
# Making it linear would add code complexity without much benefit (as it just takes ~1s for 5k nodes).
failed_nodes
=()
failed_nodes
=()
for
node
in
"
${
NODE_NAMES
[@]
}
"
;
do
for
node
in
"
${
NON_LOGEXPORTED_NODES
[@]
:-}
"
;
do
if
[[
!
"
${
nodes_succeeded
}
"
=
~
"
${
node
}
"
]]
;
then
echo
"Logexporter didn't succeed on node
${
node
}
. Queuing it for logdump through SSH."
echo
"Logexporter didn't succeed on node
${
node
}
. Queuing it for logdump through SSH."
failed_nodes+
=(
"
${
node
}
"
)
failed_nodes+
=(
"
${
node
}
"
)
fi
done
done
# Delete the logexporter resources and dump logs for the failed nodes (if any) through SSH.
# Delete the logexporter resources and dump logs for the failed nodes (if any) through SSH.
...
...
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