Skip to content

Commit

Permalink
inspect.sh: avoid logging an error if there are no core dumps (#1028)
Browse files Browse the repository at this point in the history
* inspect.sh: avoid logging an error if there are no core dumps

The inspect.sh script will log an error if the core dump dir
is empty. We'll add a check to improve the user experience.

   INFO:  Copy dmesg entries
   INFO:  Collecting core dumps from /var/crash. Size: 4.0K    /var/crash
   cp: cannot stat '/var/crash/*': No such file or directory
   Collecting snap and related information

* inspect.sh: Replace backticks

https://www.shellcheck.net/wiki/SC2006
  • Loading branch information
petrutlucian94 authored Feb 1, 2025
1 parent c97b38a commit aede013
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions k8s/scripts/inspect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ function collect_registry_mirror_logs {

function collect_core_dumps {
mkdir -p "$INSPECT_DUMP/core_dumps"
if [[ -d $CORE_DUMP_DIR ]]; then
local dump_dir_size=`du -sh $CORE_DUMP_DIR`
if [[ -d $CORE_DUMP_DIR && ! -z $(ls -A $CORE_DUMP_DIR) ]]; then
local dump_dir_size=$(du -sh $CORE_DUMP_DIR)
log_info "Collecting core dumps from $CORE_DUMP_DIR. Size: $dump_dir_size"
cp $CORE_DUMP_DIR/* "$INSPECT_DUMP/core_dumps/"
else
log_info "Core dump directory missing, skipping..."
log_info "Core dump directory empty or missing, skipping..."
fi
}

Expand Down

0 comments on commit aede013

Please sign in to comment.