-
Notifications
You must be signed in to change notification settings - Fork 235
MG-233: compress service and window node logs #554
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
bd488df
6ac1d3e
e8ce490
49394e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,13 +22,21 @@ function collect_service_logs { | |
| fi | ||
|
|
||
| mkdir -p "${DIR_PATH}" | ||
| # In CI (OPENSHIFT_CI/ARTIFACTS_DIR) skip gzip for easier inspection of artifacts | ||
| if [[ -n "${OPENSHIFT_CI:-}" || -n "${ARTIFACTS_DIR:-}" ]]; then | ||
| LOG_SUFFIX=".log" | ||
| LOG_PIPE="cat" | ||
| else | ||
| LOG_SUFFIX=".log.gz" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this be problematic for customers with existing scripts who rely on these assumptions? should we gate it behind a flag?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added it behind the flag REDUCE_LOGS. It not accepts both |
||
| LOG_PIPE="gzip" | ||
| fi | ||
| for service in "${@}"; do | ||
| echo "INFO: Collecting host service logs for $service" | ||
| if [[ ${selector} =~ '--role=' ]]; then | ||
| oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -l kubernetes.io/os=linux -u "${service}" >"${DIR_PATH}/${service}_service.log" & | ||
| oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -l kubernetes.io/os=linux -u "${service}" | ${LOG_PIPE} >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" & | ||
| PIDS+=($!) | ||
| else | ||
| oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -u "${service}" >"${DIR_PATH}/${service}_service.log" & | ||
| oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -u "${service}" | ${LOG_PIPE} >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" & | ||
|
Comment on lines
33
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Because Line 36 and Line 39 run in a pipeline and are backgrounded, Suggested fix for service in "${@}"; do
echo "INFO: Collecting host service logs for $service"
if [[ ${selector} =~ '--role=' ]]; then
- oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -l kubernetes.io/os=linux -u "${service}" | ${LOG_PIPE} >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" &
+ if [[ "${LOG_PIPE}" == "cat" ]]; then
+ oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -l kubernetes.io/os=linux -u "${service}" >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" &
+ else
+ oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -l kubernetes.io/os=linux -u "${service}" | gzip >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" &
+ fi
PIDS+=($!)
else
- oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -u "${service}" | ${LOG_PIPE} >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" &
+ if [[ "${LOG_PIPE}" == "cat" ]]; then
+ oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -u "${service}" >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" &
+ else
+ oc adm node-logs "${node_log_collection_args:---since=${SINCE_TIMEFRAME:--7d}}" "${selector}" -u "${service}" | gzip >"${DIR_PATH}/${service}_service${LOG_SUFFIX}" &
+ fi
PIDS+=($!)
fi
done🤖 Prompt for AI Agents
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== gather_service_logs_util outline =='
ast-grep outline collection-scripts/gather_service_logs_util --items all || true
printf '%s\n' '== collect_service_logs call sites and PID waits =='
rg -n -C 4 '\bcollect_service_logs\s*\(|\bwait\b|\bPIDS\b|set\s+(-o\s+pipefail|-[A-Za-z]*o?[A-Za-z]*\b)' \
-g '*.sh' -g '*.bats' .
printf '%s\n' '== pipefail declarations =='
rg -n -C 3 'pipefail' -g '*.sh' -g '*.bats' .Length of output: 5638 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== Files related to the service-log utility =='
fd -HI -t f . | rg '(^|/)(gather_service_logs_util|gather_service_logs|common)(\.[^/]+)?$|service_logs'
printf '%s\n' '== Source/call sites, PID initialization, and waits (all text files) =='
rg -n -i -C 5 \
'source[[:space:]].*gather_service_logs_util|(^|[[:space:];])\.[[:space:]].*gather_service_logs_util|\bcollect_service_logs[[:space:]]|(^|[^[:alnum:]_])PIDS=\(|\bwait[[:space:]].*PIDS|set[[:space:]]+(-[[:alpha:]]*o[[:alpha:]]*|-[[:space:]]*o[[:space:]]+pipefail)' \
--glob '!**/.git/**' .
printf '%s\n' '== Relevant production-script headers =='
for f in $(rg -l -i \
'source[[:space:]].*gather_service_logs_util|(^|[[:space:];])\.[[:space:]].*gather_service_logs_util|\bcollect_service_logs[[:space:]]' \
--glob '!**/.git/**' .); do
echo "--- $f"
sed -n '1,100p' "$f"
doneLength of output: 53367
One important correction: adding only
The robust minimal approach is to enable You are interacting with an AI system. |
||
| PIDS+=($!) | ||
| fi | ||
| done | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,14 +22,26 @@ if [ -z "$WIN_NODES" ]; then | |||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| PIDS=() | ||||||||||||||
| # In CI (OPENSHIFT_CI/ARTIFACTS_DIR) skip gzip for easier inspection of artifacts | ||||||||||||||
| if [[ -n "${OPENSHIFT_CI:-}" || -n "${ARTIFACTS_DIR:-}" ]]; then | ||||||||||||||
| WIN_LOG_SUFFIX="" | ||||||||||||||
| WIN_LOG_PIPE="cat" | ||||||||||||||
| else | ||||||||||||||
| WIN_LOG_SUFFIX=".gz" | ||||||||||||||
| WIN_LOG_PIPE="gzip" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| WINDOWS_NODE_LOGS_START=$(date +%s) | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change should be separate and is not related to the motivation of this PR
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I thought it would be better to know the actual time it takes to get the windows node logs for future analysis. We can remove it if you feel it is unnecessary. |
||||||||||||||
| echo INFO: Collecting logs for all Windows nodes | ||||||||||||||
| for log in "${LOGS[@]}"; do | ||||||||||||||
| LOG_FILE_DIR=${WINDOWS_NODE_LOGS}/log_files/$(dirname "$log") | ||||||||||||||
| mkdir -p "${LOG_FILE_DIR}" | ||||||||||||||
| /usr/bin/oc adm node-logs ${node_log_collection_args:+"$node_log_collection_args"} -l kubernetes.io/os=windows --path="$log" >"${LOG_FILE_DIR}/$(basename "$log")" & | ||||||||||||||
| /usr/bin/oc adm node-logs ${node_log_collection_args:+"$node_log_collection_args"} -l kubernetes.io/os=windows --path="$log" | ${WIN_LOG_PIPE} >"${LOG_FILE_DIR}/$(basename "$log")${WIN_LOG_SUFFIX}" & | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Backgrounded pipeline can hide At Line 39, Suggested fix- /usr/bin/oc adm node-logs ${node_log_collection_args:+"$node_log_collection_args"} -l kubernetes.io/os=windows --path="$log" | ${WIN_LOG_PIPE} >"${LOG_FILE_DIR}/$(basename "$log")${WIN_LOG_SUFFIX}" &
+ if [[ "${WIN_LOG_PIPE}" == "cat" ]]; then
+ /usr/bin/oc adm node-logs ${node_log_collection_args:+"$node_log_collection_args"} -l kubernetes.io/os=windows --path="$log" >"${LOG_FILE_DIR}/$(basename "$log")${WIN_LOG_SUFFIX}" &
+ else
+ /usr/bin/oc adm node-logs ${node_log_collection_args:+"$node_log_collection_args"} -l kubernetes.io/os=windows --path="$log" | gzip >"${LOG_FILE_DIR}/$(basename "$log")${WIN_LOG_SUFFIX}" &
+ fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| PIDS+=($!) | ||||||||||||||
| done | ||||||||||||||
| wait "${PIDS[@]}" | ||||||||||||||
| WINDOWS_NODE_LOGS_END=$(date +%s) | ||||||||||||||
| echo "INFO: Windows node log collection completed in $((WINDOWS_NODE_LOGS_END - WINDOWS_NODE_LOGS_START)) seconds" | ||||||||||||||
|
|
||||||||||||||
| # force disk flush to ensure that all data gathered is accessible in the copy container | ||||||||||||||
| sync | ||||||||||||||
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.
Instead of assigning in else statement, it is better to default to these values and only modify the compress_service_logs is true