tests: Add k3s artifacts

The k3s distribution of k8s uses an embedded version of containerd and
configures it to log to a file, not the journal. Hence, although we
collect the journal as a test artifact, we also need to collect the
actual log files for containerd.

Also collect the k3s containerd config files to help with debugging.

Fixes: #9104.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt
2024-03-05 17:28:09 +00:00
parent 9fab57acc8
commit a67ed2f1c2

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() {