Commit Graph

16 Commits

Author SHA1 Message Date
Botond Dénes
ea8478a3e7 scripts/open-coredump.sh: introduce --ci
Coredumps coming from CI are produced by a commit, which is not
available in the scylla.git repository, as CI runs on a merge commit
between the main branch (master or enterprise) and the tested PR branch.
Currently the script will attempt to checkout this commit and will fail
as the commit hash is unrecognized.
To work around this, add a --ci flag, which when used, will force the
main branch to be checked out, instead of the commit hash.

Closes scylladb/scylladb#18023
2024-04-02 09:27:52 +03:00
Michał Chojnowski
75864e18a2 open-coredump.sh: respect http redirects
downloads.scylladb.com recently started redirecting from http to https
(via `301 Moved Permanently`).
This broke package downloading in open-coredump.sh.

To fix this, we have to instruct curl to follow redirects.

Closes scylladb/scylladb#17759
2024-03-13 08:57:04 +02:00
Benny Halevy
08b0426318 scripts/open-coredump.sh: calculate MAIN_BRANCH before cloning repo
We need MAIN_BRANCH calculated earlier so we can use it
to checkout the right branch when cloning the src repo
(either `master` or `enterprise`, based on the detected `PRODUCT`)

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>

Closes scylladb/scylladb#17647
2024-03-06 09:46:30 +02:00
Yaniv Kaul
c658bdb150 Typos: fix typos in comments
Fixes some typos as found by codespell run on the code.
In this commit, I was hoping to fix only comments, not user-visible alerts, output, etc.
Follow-up commits will take care of them.

Refs: https://github.com/scylladb/scylladb/issues/16255
Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
2023-12-02 22:37:22 +02:00
Kefu Chai
dd59b90999 open-coredump: pass the content of "image" file not its path to dbuild
in a4eb3c6e0f, we passed the path of
"image" to `dbuild`, but that was wrong. we should pass its content
to this script. so in this change, it is fixed.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #15247
2023-09-04 07:34:44 +03:00
Kefu Chai
a4eb3c6e0f open-coredump: use the dbuild script in current branch
the dbuild script provided by the branch being debugged might not
include the recent fixes included by current branch from which
`open-coredump.sh` is launched.

so, instead of using the dbuild script in the repo being debugged,
let's use the dbuild provided by current branch. also, wrap the
dbuild command line. for better readability.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #15240
2023-09-01 07:27:21 +03:00
Kefu Chai
3bdbe620aa open-coredump: do not assume remote repo name
open-coredump.sh allows us to specify --scylla-repo-path, but
developer's remote repo name is not always "origin" -- the
"origin" could be his/her own remote repo. not the one from which
we want to pull from.

so, in this change, assuming that the remote repo to be pulled
from has been added to the local repo, we query the local repo
for its name and pull using that name instead.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #15220
2023-08-31 08:04:28 +03:00
Kefu Chai
a47dcb29d5 open-coredump: add selinux label to shared volume
before this change, we don't configure the selinux label when
binding shared volume, but this results in permission denied
when accessing `/opt/scylladb` in the container when the selinux
is enabled. since we are not likely to share the volume with
other containers, we can use `Z` to indicate that the bind
mount is private and unshared. this allows the launched container
to access `/opt/scylladb` even if selinux is enabled.

since selinux is enabled by default on a installation of fedora 38.
this change should improve the user experience of open-coredump
when developer uses fedora distributions.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #15229
2023-08-31 08:03:40 +03:00
Pavel Emelyanov
ec292721d6 open_coredump: Add --scylla-build-id CLI option
The script gets the build id on its own but eu-unstrip-ing the core file
and searching for the necessary value in the output. This can be
somewhat lenghthy operation especially on huge core files. Sometimes
(e.g. in tests) the build id is known and can be just provided as an
argument.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>

Closes #14574
2023-07-10 11:17:54 +03:00
Pavel Emelyanov
577cd96da8 scripts: Fix options iteration in open-coredump.sh
When run like 'open-coredump.sh --help' the options parsing loop doesn't
run because $# == 1 and [ $# -gt 1 ] evaluates to false.

The simplest fix is to parse -h|--help on its own as the options parsing
loop assumes that there's core-file argument present.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>

Closes #14075
2023-05-30 12:25:01 +03:00
Michał Sala
3b44ecd1e7 scripts: open-coredump.sh: suggest solib-search-path
Loading cores from Scylla executables installed in a non-standard
location can cause gdb to fail reading required libraries.

This is an example of a warning I've got after trying to load core
generated by dtest jenkins job (using ./scripts/open-coredump.sh):
> warning: Can't open file /jenkins/workspace/scylla-master/dtest-daily-debug/scylla/.ccm/scylla-repository/0d64f327e1af9bcbb711ee217eda6df16e517c42/libreloc/libboost_system.so.1.78.0 during file-backed mapping note processing

Invocations of `scylla threads` command ended with an error:
> (gdb) scylla threads
> Python Exception <class 'gdb.error'>: Cannot find thread-local storage for LWP 2758, executable file (...)/scylla-debug-unstripped-5.3.0~dev-0.20230121.0d64f327e1af.x86_64/scylla/libexec/scylla:
> Cannot find thread-local variables on this target
> Error occurred in Python: Cannot find thread-local storage for LWP 2758, executable file (...)/scylla-debug-unstripped-5.3.0~dev-0.20230121.0d64f327e1af.x86_64/scylla/libexec/scylla:
> Cannot find thread-local variables on this target

An easy fix for this is to set solib-search-path to
/opt/scylladb/libreloc/.

This commit adds that set command to suggested command line gdb
arguments. I guess it's a good idea to always suggest setting
solib-search-path to that path, as it can save other people from wasting
their time on looking why does coredump opening does not work.

Closes #13696
2023-04-28 08:11:01 +03:00
Botond Dénes
cae79ef2c3 scripts/open-coredump.sh: allow bypassing the package downloading
By allowing the user to plug a manually downloaded package. Consequently
the "package_url" field of the build metadata is checked only if there
is no user-provided extracted package.
This allows working around builds for which the metadata server returns
no "package_url", by allowing the user to locate and download the
package themselves, providing it to the script by simply extracting it
as $ARTIFACT_DIR/scylla.package.
2023-04-14 07:48:21 -04:00
Botond Dénes
45fbdbe5f7 scripts/open-coredump.sh: check presence of mandatory field in build json object
Mandatory fields missing in the build json object lead to obscure,
unrelated error messages down the road. Avoid this by checking that all
required fields all present and print an error message if any is
missing.
2023-04-14 07:33:46 -04:00
Botond Dénes
4df5ec4080 scripts/open-coredump.sh: more consistent error messaging
Start all erro messages with "error: ..." and log them to stderr.
2023-04-14 07:24:14 -04:00
Botond Dénes
ab8171ffd5 open-coredump.sh: handle dev versions
Like: 5.2.0~dev, which really means master. Don't try to checkout
branch-5.2 in this case, it doesn't exist yet, checkout master instead.

Closes #12510
2023-01-12 19:28:58 +02:00
Botond Dénes
d44c5f5548 scripts: add open-coredump.sh
Script for "one-click" opening of coredumps.
It extracts the build-id from the coredump, retrieves metadata for that
build, downloads the binary package, the source code and finally
launches the dbuild container, with everything ready to load the
coredump.
The script is idempotent: running it after the prepartory steps will
re-use what is already donwloaded.

The script is not trying to provide a debugging environment that caters
to all the different ways and preferences of debugging. Instead, it just
sets up a minimalistic environment for debugging, while providing
opportunities for the user to customization according to their
preferred.

I'm not entirely sure, coredumps from master branch will work, but we
can address this later when we confirm they don't.

Example:

    $ ~/ScyllaDB/scylla/worktree0/scripts/open-coredump.sh ./core.scylla.113.bac3650b616f4f09a4d1ab160574b6a5.4349.1669185225000000000000
    Build id: 5009658b834aaf68970135bfc84f964b66ea4dee
    Matching build is scylla-5.0.5 0.20221009.5a97a1060 release-x86_64
    Downloading relocatable package from http://downloads.scylladb.com/downloads/scylla/relocatable/scylladb-5.0/scylla-x86_64-package-5.0.5.0.20221009.5a97a1060.tar.gz
    Extracting package scylla-x86_64-package-5.0.5.0.20221009.5a97a1060.tar.gz
    Cloning scylla.git
    Downloading scylla-gdb.py
    Copying scylla-gdb.py from /home/bdenes/ScyllaDB/storage/11961/open-coredump.sh.dir/scylla.repo
    Launching dbuild container.

    To examine the coredump with gdb:

        $ gdb -x scylla-gdb.py -ex 'set directories /src/scylla' --core ./core.scylla.113.bac3650b616f4f09a4d1ab160574b6a5.4349.1669185225000000000000 /opt/scylladb/libexec/scylla

    See https://github.com/scylladb/scylladb/blob/master/docs/dev/debugging.md for more information on how to debug scylla.

    Good luck!
    [root@fedora workdir]#

Closes #12223
2022-12-12 12:55:28 +02:00