Skip to content
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

MDBF-814 for install/upgrade save logs on failure #607

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

grooverdan
Copy link
Member

This applies to Columnstore logs, data

core files also saved.

Also saves the systemd journal of applicable services.

Being an trap ERR it will execute only if an err occurs hence if conditions on columnstore SQL removed.

Unsure on if clean of the logdir is needed.

@@ -437,22 +439,40 @@ upgrade_test_type() {
esac
}

get_columnstore_logs() {
save_failure_logs() {
local logdir=/home/buildbot/logs/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we use relative path? this has proven to be fragile on mac freebsd and other OS. I know we don't have install/upgrade test there but relative is better if possible since it makes it possible to have both dev and prod builders on the same machine...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which relative path ../logs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be tested but yes, probably

scripts/bash_lib.sh Outdated Show resolved Hide resolved
scripts/bash_lib.sh Outdated Show resolved Hide resolved
@grooverdan grooverdan force-pushed the MDBF-814-save-cs-logs branch 2 times, most recently from 2996864 to 291c49c Compare November 6, 2024 22:53
@@ -4,6 +4,8 @@
# Include with:
# . ./bash_lib.sh

trap save_failure_logs ERR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen to the other failure points that don't need log collection? I suppose they will trigger log collection, reacting on the ERR signal of a command.

There are some code blocks which are not related to:

  • installation / upgrade process of the server

  • running queries to create or verify structures in the db

For example, blocks where we set-up the repository, make cache, query the repo and so on.

What I want to highlight is this most basic example:

set -e
trap save_failure_logs ERR

save_failure_logs() {
  trap "" ERR
  echo "I just saved the logs for Columnstore and MariaDB-Server"
}

echo "I am doing some pre-setup before Installing the Server"
echo "Presetup will fail, I have nothing installed. Do I really need to collect the logs?"

non_existent_command

Copy link
Collaborator

@RazvanLiviuVarzaru RazvanLiviuVarzaru Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like more the explicit approach in which we test the command and save the logs in case of a failure.
I am not in favor of trap because is fragile in case another command fails, before we need to actually look at the logs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

traps are set after initial setup when any of the following commands can be meaningfully triggered by a server fault. The set +e to disable is at the end of the block if there becomes a big of adminstration.

Even a missing command will be during the process and evaluating some aspect of the package is correct. If this is the case its an error also. Maybe the logs unneeded in this case, but the failure is still required.

@grooverdan grooverdan force-pushed the MDBF-814-save-cs-logs branch 2 times, most recently from d0147de to e248708 Compare November 13, 2024 04:01
fi
set -u

sudo "$pkg_cmd" -n install "${package_array[@]}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that on non-SUSE VM's , -n works?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, missed the -n /-y difference - reverted back.

echo "$pkg_list" | xargs sudo "$pkg_cmd" -n install
else
echo "$pkg_list" | xargs sudo "$pkg_cmd" -y install
if [ ${#package_array[@]} -eq 0 ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this will work but refactoring other parts makes things really hard to follow in the scope of this MDBF.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. merged off.

bb_log_err "installation of a previous release failed, see the output above"
#fi
save_failure_logs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are mixing approaches i.e. :

  1. command failures handled by IF or || need an explicit save_failure_logs call
  2. other command failures are handled by trap save_failure_logs ERR

Why don't we stick to one across all scripts? Makes it easier to read. And it's easy to document how we handle errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Unsure if documentation is complete enough.

@@ -468,10 +479,7 @@ check_mariadb_server_and_create_structures() {
sudo mariadb -e "CREATE PROCEDURE db.p() SELECT * FROM db.v_merge"
sudo mariadb -e "CREATE FUNCTION db.f() RETURNS INT DETERMINISTIC RETURN 1"
if [[ $test_mode == "columnstore" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A failure here is handled in the parent script i.e. deb/rpm - upgrade?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, set -e/+e in this function incorrect.

This makes it more generic and expands the columnstore saving
to the required information.
* service logs
* columnstore data dir (tar.bz2)
* /tmp/columnstore_tmp_files (appended to log file)

More information like the mariadb.service journal and coredumps are saved.
@grooverdan grooverdan force-pushed the MDBF-814-save-cs-logs branch from e248708 to 9214b9f Compare November 27, 2024 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants