-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not crash on empty NODE_NAMES array. #55682
Conversation
/assign @roberthbailey
|
/test pull-kubernetes-e2e-kops-aws |
cluster/log-dump/log-dump.sh
Outdated
@@ -232,7 +232,7 @@ function dump_nodes() { | |||
else | |||
echo "Detecting nodes in the cluster" | |||
detect-node-names &> /dev/null | |||
node_names=( "${NODE_NAMES[@]}" ) | |||
node_names=( "${NODE_NAMES[@]:+${NODE_NAMES[@]}}" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is making the script hard to understand. Instead of changes like this here and below, I guess you can simply do the following:
if [[ -n "${NODE_NAMES:-}" ]]; then
node_names=( "${NODE_NAMES[@]}" )
fi
The code further should handle the case that node_names
is empty.
cluster/log-dump/log-dump.sh
Outdated
@@ -306,7 +306,7 @@ function dump_nodes_with_logexporter() { | |||
if ! "${KUBECTL}" create -f "${KUBE_ROOT}/cluster/log-dump/logexporter-daemonset.yaml"; then | |||
echo "Failed to create logexporter daemonset.. falling back to logdump through SSH" | |||
"${KUBECTL}" delete namespace "${logexporter_namespace}" || true | |||
dump_nodes "${NODE_NAMES[@]}" | |||
dump_nodes "${NODE_NAMES[@]:+${NODE_NAMES[@]}}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also, instead of making this change at 3 places inside the function. I would suggest changing the above condition in L286 to:
if [[ -z "${NODE_NAMES:-}" ]]; then
echo "No nodes found!"
return
fi
Simplified. |
cluster/log-dump/log-dump.sh
Outdated
@@ -232,7 +232,9 @@ function dump_nodes() { | |||
else | |||
echo "Detecting nodes in the cluster" | |||
detect-node-names &> /dev/null | |||
node_names=( "${NODE_NAMES[@]}" ) | |||
if (( ${#NODE_NAMES[@]} )); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also change similar if condition inside dump_nodes_with_logexporter()
.
770c21c
to
de250ed
Compare
squashed |
Done.
|
de250ed
to
310ab8c
Compare
/lgtm @zmerlynn / @roberthbailey Could one of you please approve the PR? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: porridge, roberthbailey, shyamjvs Associated issue: 55675 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Review the full test history for this PR. |
/test all [submit-queue is verifying that this PR is safe to merge] |
@porridge: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Automatic merge from submit-queue (batch tested with PRs 55682, 55444, 55456, 55717, 55131). If you want to cherry-pick this change to another branch, please follow the instructions here. |
1 similar comment
Automatic merge from submit-queue (batch tested with PRs 55682, 55444, 55456, 55717, 55131). If you want to cherry-pick this change to another branch, please follow the instructions here. |
Which issue(s) this PR fixes:
Fixes #55675
Release note: