Merge pull request #9223 from jodh-intel/tests-add-k3s-artifacts

tests: Add k3s artifacts
This commit is contained in:
GabyCT 2024-03-05 13:37:21 -06:00 committed by GitHub
commit 83e39a206c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -243,6 +243,53 @@ function collect_artifacts() {
local journalctl_log_filename="journalctl.log"
local journalctl_log_path="${artifacts_dir}/${journalctl_log_filename}"
sudo journalctl --since="$start_time" > "${journalctl_log_path}"
local k3s_dir='/var/lib/rancher/k3s/agent'
if [ -d "$k3s_dir" ]
then
info "Collecting k3s artifacts"
local -a files=()
files+=('etc/containerd/config.toml')
files+=('etc/containerd/config.toml.tmpl')
files+=('containerd/containerd.log')
# Add any rotated containerd logs
files+=( $(sudo find \
"${k3s_dir}/containerd/" \
-type f \
-name 'containerd*\.log\.gz') )
local file
for file in "${files[@]}"
do
local path="$k3s_dir/$file"
sudo [ ! -e "$path" ] && continue
local encoded
encoded=$(echo "$path" | tr '/' '-' | sed 's/^-//g')
local from="$path"
local to
to="${artifacts_dir}/${encoded}"
if [[ $path = *.gz ]]
then
sudo cp "$from" "$to"
else
to="${to}.gz"
sudo gzip -c "$from" > "$to"
fi
info " Collected k3s file '$from' to '$to'"
done
fi
}
function cleanup_kata_deploy() {