mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-25 18:53:44 +00:00
Merge pull request #7240 from dborquez/storing_metrics_artifacts
metrics: storing metrics workflow artifacts
This commit is contained in:
11
.github/workflows/run-metrics.yaml
vendored
11
.github/workflows/run-metrics.yaml
vendored
@@ -42,3 +42,14 @@ jobs:
|
||||
|
||||
- name: run blogbench test
|
||||
run: bash tests/metrics/gha-run.sh run-test-blogbench
|
||||
|
||||
- name: make metrics tarball ${{ matrix.vmm }}
|
||||
run: bash tests/metrics/gha-run.sh make-tarball-results
|
||||
|
||||
- name: archive metrics results ${{ matrix.vmm }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: metrics-artifacts-${{ matrix.vmm }}
|
||||
path: results-${{ matrix.vmm }}.tar.gz
|
||||
retention-days: 1
|
||||
if-no-files-found: error
|
||||
|
@@ -240,3 +240,17 @@ restart_containerd_service() {
|
||||
clean_env_ctr
|
||||
return 0
|
||||
}
|
||||
|
||||
# @path_results: path to the input metric-results folder
|
||||
# @tarball_fname: path and filename to the output tarball
|
||||
function compress_metrics_results_dir()
|
||||
{
|
||||
local path_results="${1:-results}"
|
||||
local tarball_fname="${2:-}"
|
||||
|
||||
[ -z "${tarball_fname}" ] && die "Missing the tarball filename or the path to save the tarball results is incorrect."
|
||||
[ ! -d "${path_results}" ] && die "Missing path to the results folder."
|
||||
|
||||
cd "${path_results}" && tar -czf "${tarball_fname}" *.json && cd -
|
||||
info "tarball generated: ${tarball_fname}"
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ set -o pipefail
|
||||
kata_tarball_dir="${2:-kata-artifacts}"
|
||||
metrics_dir="$(dirname "$(readlink -f "$0")")"
|
||||
source "${metrics_dir}/../common.bash"
|
||||
source "${metrics_dir}/lib/common.bash"
|
||||
|
||||
declare -r results_dir="${metrics_dir}/results"
|
||||
declare -r checkmetrics_dir="${metrics_dir}/cmd/checkmetrics"
|
||||
@@ -104,6 +105,10 @@ function check_metrics() {
|
||||
fi
|
||||
}
|
||||
|
||||
function make_tarball_results() {
|
||||
compress_metrics_results_dir "${metrics_dir}/results" "${GITHUB_WORKSPACE}/results-${KATA_HYPERVISOR}.tar.gz"
|
||||
}
|
||||
|
||||
function run_test_launchtimes() {
|
||||
info "Running Launch Time test using ${KATA_HYPERVISOR} hypervisor"
|
||||
|
||||
@@ -144,6 +149,7 @@ function main() {
|
||||
action="${1:-}"
|
||||
case "${action}" in
|
||||
install-kata) install_kata ;;
|
||||
make-tarball-results) make_tarball_results ;;
|
||||
run-test-launchtimes) run_test_launchtimes ;;
|
||||
run-test-memory-usage) run_test_memory_usage ;;
|
||||
run-test-memory-usage-inside-container) run_test_memory_usage_inside_container ;;
|
||||
|
@@ -47,14 +47,14 @@ quay.io/libpod"
|
||||
#
|
||||
# cmds=(“cmd1” “cmd2”)
|
||||
# check_cmds "${cmds[@]}"
|
||||
check_cmds()
|
||||
function check_cmds()
|
||||
{
|
||||
local cmd req_cmds=( "$@" )
|
||||
for cmd in "${req_cmds[@]}"; do
|
||||
if ! command -v "$cmd" > /dev/null 2>&1; then
|
||||
die "command $cmd not available"
|
||||
fi
|
||||
echo "command: $cmd: yes"
|
||||
info "command: $cmd: yes"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -68,19 +68,20 @@ check_cmds()
|
||||
#
|
||||
# images=(“img1” “img2”)
|
||||
# check_imgs "${images[@]}"
|
||||
check_images()
|
||||
function check_images()
|
||||
{
|
||||
local img req_images=( "$@" )
|
||||
for img in "${req_images[@]}"; do
|
||||
echo "ctr pull'ing: $img"
|
||||
info "ctr pull'ing: $img"
|
||||
if ! sudo "${CTR_EXE}" image pull "$img"; then
|
||||
die "Failed to pull image $img"
|
||||
fi
|
||||
echo "ctr pull'd: $img"
|
||||
info "ctr pull'd: $img"
|
||||
done
|
||||
}
|
||||
|
||||
generate_build_dockerfile() {
|
||||
function generate_build_dockerfile()
|
||||
{
|
||||
local dockerfile="$1"
|
||||
local image="$2"
|
||||
local map_key="$3"
|
||||
@@ -99,14 +100,14 @@ generate_build_dockerfile() {
|
||||
# This function performs a build on the image names
|
||||
# passed in, to ensure that we have the latest changes from
|
||||
# the dockerfiles
|
||||
build_dockerfile_image()
|
||||
function build_dockerfile_image()
|
||||
{
|
||||
local image="$1"
|
||||
local dockerfile_path="$2"
|
||||
local dockerfile_dir=${2%/*}
|
||||
|
||||
if [ -f "$dockerfile_path" ]; then
|
||||
echo "docker building $image"
|
||||
info "docker building $image"
|
||||
if ! sudo "${DOCKER_EXE}" build --build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" --label "$image" --tag "${image}" -f "$dockerfile_path" "$dockerfile_dir"; then
|
||||
die "Failed to docker build image $image"
|
||||
fi
|
||||
@@ -119,7 +120,7 @@ build_dockerfile_image()
|
||||
|
||||
# This function removes the ctr image, builds a new one using a dockerfile
|
||||
# and imports the image from docker to ctr
|
||||
check_ctr_images()
|
||||
function check_ctr_images()
|
||||
{
|
||||
local ctr_image="$1"
|
||||
local dockerfile_path="$2"
|
||||
@@ -138,7 +139,7 @@ check_ctr_images()
|
||||
|
||||
# A one time (per uber test cycle) init that tries to get the
|
||||
# system to a 'known state' as much as possible
|
||||
metrics_onetime_init()
|
||||
function metrics_onetime_init()
|
||||
{
|
||||
# The onetime init must be called once, and only once
|
||||
if [ ! -z "$onetime_init_done" ]; then
|
||||
@@ -155,14 +156,14 @@ metrics_onetime_init()
|
||||
|
||||
# Print a banner to the logs noting clearly which test
|
||||
# we are about to run
|
||||
test_banner()
|
||||
function test_banner()
|
||||
{
|
||||
echo -e "\n===== starting test [$1] ====="
|
||||
info -e "\n===== starting test [$1] ====="
|
||||
}
|
||||
|
||||
# Initialization/verification environment. This function makes
|
||||
# minimal steps for metrics/tests execution.
|
||||
init_env()
|
||||
function init_env()
|
||||
{
|
||||
test_banner "${TEST_NAME}"
|
||||
|
||||
@@ -183,7 +184,8 @@ init_env()
|
||||
# This function checks if there are containers or
|
||||
# shim/proxy/hypervisor processes up, if found, they are
|
||||
# killed to start test with clean environment.
|
||||
kill_processes_before_start() {
|
||||
function kill_processes_before_start()
|
||||
{
|
||||
DOCKER_PROCS=$(sudo "${DOCKER_EXE}" ps -q)
|
||||
[[ -n "${DOCKER_PROCS}" ]] && clean_env
|
||||
|
||||
@@ -195,26 +197,29 @@ kill_processes_before_start() {
|
||||
|
||||
# Generate a random name - generally used when creating containers, but can
|
||||
# be used for any other appropriate purpose
|
||||
random_name() {
|
||||
function random_name()
|
||||
{
|
||||
mktemp -u kata-XXXXXX
|
||||
}
|
||||
|
||||
show_system_ctr_state() {
|
||||
echo "Showing system state:"
|
||||
echo " --Check containers--"
|
||||
function show_system_ctr_state()
|
||||
{
|
||||
info "Showing system state:"
|
||||
info " --Check containers--"
|
||||
sudo "${CTR_EXE}" c list
|
||||
echo " --Check tasks--"
|
||||
info " --Check tasks--"
|
||||
sudo "${CTR_EXE}" task list
|
||||
|
||||
local processes="containerd-shim-kata-v2"
|
||||
|
||||
for p in ${processes}; do
|
||||
echo " --pgrep ${p}--"
|
||||
info " --pgrep ${p}--"
|
||||
pgrep -a ${p}
|
||||
done
|
||||
}
|
||||
|
||||
common_init(){
|
||||
function common_init()
|
||||
{
|
||||
if [ "$CTR_RUNTIME" == "io.containerd.kata.v2" ] || [ "$RUNTIME" == "containerd-shim-kata-v2" ]; then
|
||||
extract_kata_env
|
||||
else
|
||||
@@ -225,17 +230,18 @@ common_init(){
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Save the current KSM settings so we can restore them later
|
||||
save_ksm_settings(){
|
||||
echo "saving KSM settings"
|
||||
function save_ksm_settings()
|
||||
{
|
||||
info "saving KSM settings"
|
||||
ksm_stored_run=$(cat ${KSM_ENABLE_FILE})
|
||||
ksm_stored_pages=$(cat ${KSM_ENABLE_FILE})
|
||||
ksm_stored_sleep=$(cat ${KSM_ENABLE_FILE})
|
||||
}
|
||||
|
||||
set_ksm_aggressive(){
|
||||
echo "setting KSM to aggressive mode"
|
||||
function set_ksm_aggressive()
|
||||
{
|
||||
info "setting KSM to aggressive mode"
|
||||
# Flip the run off/on to ensure a restart/rescan
|
||||
sudo bash -c "echo 0 > ${KSM_ENABLE_FILE}"
|
||||
sudo bash -c "echo ${KSM_AGGRESIVE_PAGES} > ${KSM_PAGES_FILE}"
|
||||
@@ -245,7 +251,7 @@ set_ksm_aggressive(){
|
||||
if [ "${KATA_HYPERVISOR}" == "qemu" ]; then
|
||||
# Disable virtio-fs and save whether it was enabled previously
|
||||
set_virtio_out=$(sudo -E PATH="$PATH" "${LIB_DIR}/../../.ci/set_kata_config.sh" shared_fs virtio-9p)
|
||||
echo "${set_virtio_out}"
|
||||
info "${set_virtio_out}"
|
||||
grep -q "already" <<< "${set_virtio_out}" || was_virtio_fs=true;
|
||||
fi
|
||||
}
|
||||
@@ -256,8 +262,9 @@ restore_virtio_fs(){
|
||||
info "Not restoring virtio-fs since it wasn't enabled previously"
|
||||
}
|
||||
|
||||
restore_ksm_settings(){
|
||||
echo "restoring KSM settings"
|
||||
function restore_ksm_settings()
|
||||
{
|
||||
info "restoring KSM settings"
|
||||
# First turn off the run to ensure if we are then re-enabling
|
||||
# that any changes take effect
|
||||
sudo bash -c "echo 0 > ${KSM_ENABLE_FILE}"
|
||||
@@ -267,15 +274,17 @@ restore_ksm_settings(){
|
||||
[ "${KATA_HYPERVISOR}" == "qemu" ] && restore_virtio_fs
|
||||
}
|
||||
|
||||
disable_ksm(){
|
||||
echo "disabling KSM"
|
||||
function disable_ksm()
|
||||
{
|
||||
info "disabling KSM"
|
||||
sudo bash -c "echo 0 > ${KSM_ENABLE_FILE}"
|
||||
[ "${KATA_HYPERVISOR}" == "qemu" ] && restore_virtio_fs
|
||||
}
|
||||
|
||||
# See if KSM is enabled.
|
||||
# If so, amend the test name to reflect that
|
||||
check_for_ksm(){
|
||||
function check_for_ksm()
|
||||
{
|
||||
if [ ! -f ${KSM_ENABLE_FILE} ]; then
|
||||
return
|
||||
fi
|
||||
@@ -294,7 +303,8 @@ check_for_ksm(){
|
||||
# a full scan has managed to do few new merges)
|
||||
#
|
||||
# arg1 - timeout in seconds
|
||||
wait_ksm_settle(){
|
||||
function wait_ksm_settle()
|
||||
{
|
||||
[[ "$RUNTIME" == "runc" ]] || [[ "$CTR_RUNTIME" == "io.containerd.runc.v2" ]] && return
|
||||
local t pcnt
|
||||
local oldscan=-1 newscan
|
||||
@@ -305,7 +315,7 @@ wait_ksm_settle(){
|
||||
# Wait some time for KSM to kick in to avoid early dismissal
|
||||
for ((t=0; t<5; t++)); do
|
||||
pages=$(cat "${KSM_PAGES_SHARED}")
|
||||
[[ "$pages" -ne 0 ]] && echo "Discovered KSM activity" && break
|
||||
[[ "$pages" -ne 0 ]] && info "Discovered KSM activity" && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
@@ -315,13 +325,13 @@ wait_ksm_settle(){
|
||||
|
||||
newscan=$(cat /sys/kernel/mm/ksm/full_scans)
|
||||
newpages=$(cat "${KSM_PAGES_SHARED}")
|
||||
[[ "$newpages" -eq 0 ]] && echo "No need to wait for KSM to settle" && return
|
||||
[[ "$newpages" -eq 0 ]] && info "No need to wait for KSM to settle" && return
|
||||
|
||||
if (( newscan != oldscan )); then
|
||||
echo -e "\nnew full_scan ($oldscan to $newscan)"
|
||||
info -e "\nnew full_scan ($oldscan to $newscan)"
|
||||
|
||||
# Do we have a previous scan to compare with
|
||||
echo "check pages $oldpages to $newpages"
|
||||
info "check pages $oldpages to $newpages"
|
||||
|
||||
if (( oldpages != -1 )); then
|
||||
# avoid divide by zero problems
|
||||
@@ -330,14 +340,14 @@ wait_ksm_settle(){
|
||||
# abs()
|
||||
pcnt=$(( $pcnt * -1 ))
|
||||
|
||||
echo "$oldpages to $newpages is ${pcnt}%"
|
||||
info "$oldpages to $newpages is ${pcnt}%"
|
||||
|
||||
if (( $pcnt <= 5 )); then
|
||||
echo "KSM stabilised at ${t}s"
|
||||
info "KSM stabilised at ${t}s"
|
||||
return
|
||||
fi
|
||||
else
|
||||
echo "$oldpages KSM pages... waiting"
|
||||
info "$oldpages KSM pages... waiting"
|
||||
fi
|
||||
fi
|
||||
oldscan=$newscan
|
||||
@@ -347,7 +357,7 @@ wait_ksm_settle(){
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "Timed out after ${1}s waiting for KSM to settle"
|
||||
info "Timed out after ${1}s waiting for KSM to settle"
|
||||
}
|
||||
|
||||
common_init
|
||||
|
Reference in New Issue
Block a user