-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Error monitoring of the self-hosted installer #1679
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
1db7817
WIP
emmatyping 5c7b28d
WIP 2
emmatyping 8c9c4fb
More minimal but quite functional error reporting
emmatyping 4cfc994
Update project name to installer, tweak wording based on legal
emmatyping c307013
Update install/error-handling.sh
emmatyping d280ae0
Respond to review
emmatyping 8bb9a33
Change org name
emmatyping 1d78003
Put detect-platform in the right spot in install.sh
emmatyping b1f229c
Move .reporterrors to distro root
emmatyping 7fa54b2
Update copy and fix .reporterrors location (#1686)
chadwhitacre 45bf865
fix unexpected behavior with traceback code
hubertdeng123 fee3d51
Move retcode as well
chadwhitacre c6fa96b
Fix over-indentation
chadwhitacre 55a8d59
Swing back a bit towards previous
chadwhitacre 6c175d8
fix sentry-cli for linux/amd64
hubertdeng123 a966c1e
add sentry org and project to env variables for dockerized sentry-cli
hubertdeng123 de504d8
Don't prompt for .reporterrors if non-reportable
chadwhitacre 6a8ee8c
Don't report errors by default
chadwhitacre 382d2bf
use dockerized sentry-cli for arm64
hubertdeng123 0e1239c
fix broken error-handling script
hubertdeng123 5df2ab6
Pull sentry-cli early so we can fail gracefully
chadwhitacre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| # Error reporting choice cache | ||
| .reporterrors | ||
|
|
||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,112 @@ | ||
| echo "${_group}Setting up error handling ..." | ||
|
|
||
| export SENTRY_DSN='https://[email protected]/3' | ||
| export SENTRY_ORG=self-hosted | ||
| export SENTRY_PROJECT=installer | ||
| export REPORT_ERRORS=0 | ||
|
|
||
| function send_event { | ||
| local sentry_cli="docker run --rm -v $basedir:/work -e SENTRY_ORG=$SENTRY_ORG -e SENTRY_PROJECT=$SENTRY_PROJECT -e SENTRY_DSN=$SENTRY_DSN getsentry/sentry-cli" | ||
| command pushd .. > /dev/null | ||
| $sentry_cli send-event --no-environ -f "$1" -m "$2" --logfile $log_file | ||
| command popd > /dev/null | ||
| } | ||
|
|
||
| reporterrors="$basedir/.reporterrors" | ||
| if [[ -f $reporterrors ]]; then | ||
| echo -n "Found a .reporterrors file. What does it say? " | ||
| cat $reporterrors | ||
| if [[ "$(cat $reporterrors)" == "yes" ]]; then | ||
| export REPORT_ERRORS=1 | ||
| else | ||
| export REPORT_ERRORS=0 | ||
| fi | ||
| else | ||
| echo | ||
| echo "Hey, so ... we would love to find out when you hit an issue with this here" | ||
| echo "installer you are running. Turns out there is an app for that, called Sentry." | ||
| echo "Are you okay with us sending info to Sentry when you run this installer?" | ||
| echo | ||
| echo " y / yes / 1" | ||
| echo " n / no / 0" | ||
| echo | ||
| echo "(Btw, we send this to our own self-hosted Sentry instance, not to Sentry SaaS," | ||
| echo "so that we can be in this together.)" | ||
| echo | ||
| echo "Here's the info we may collect in order to help us improve the installer:" | ||
| echo | ||
| echo " - OS username" | ||
| echo " - IP address" | ||
| echo " - install log" | ||
| echo " - performance data" | ||
| echo | ||
| echo "Thirty (30) day retention. No marketing. Privacy policy at sentry.io/privacy." | ||
| echo | ||
|
|
||
| yn="" | ||
| until [ ! -z "$yn" ] | ||
| do | ||
| read -p "y or n? " yn | ||
| case $yn in | ||
| y | yes | 1) export REPORT_ERRORS=1; echo "yes" > $reporterrors; echo; echo -n "Thank you.";; | ||
| n | no | 0) export REPORT_ERRORS=0; echo "no" > $reporterrors; echo; echo -n "Understood.";; | ||
| *) yn="";; | ||
| esac | ||
| done | ||
|
|
||
| echo " Your answer is cached in '.reporterrors', remove it to see this" | ||
| echo "prompt again." | ||
| echo | ||
| sleep 5 | ||
| fi | ||
|
|
||
| # Make sure we can use sentry-cli if we need it. | ||
| if [ "$REPORT_ERRORS" == 1 ]; then | ||
| if ! docker pull getsentry/sentry-cli:latest; then | ||
| echo "Failed to pull sentry-cli, won't report errors after all." | ||
| export REPORT_ERRORS=0 | ||
| fi; | ||
| fi; | ||
|
|
||
| # Courtesy of https://stackoverflow.com/a/2183063/90297 | ||
| trap_with_arg() { | ||
| func="$1" ; shift | ||
| for sig ; do | ||
| trap "$func $sig "'$LINENO' "$sig" | ||
emmatyping marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| trap "$func $sig" "$sig" | ||
| done | ||
| } | ||
|
|
||
| DID_CLEAN_UP=0 | ||
| # the cleanup function will be the exit point | ||
| cleanup () { | ||
| local retcode=$? | ||
| local cmd="${BASH_COMMAND}" | ||
chadwhitacre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if [[ "$DID_CLEAN_UP" -eq 1 ]]; then | ||
| return 0; | ||
| fi | ||
| DID_CLEAN_UP=1 | ||
|
|
||
| if [[ "$1" != "EXIT" ]]; then | ||
| echo "An error occurred, caught SIG$1 on line $2"; | ||
| set +o xtrace | ||
chadwhitacre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| printf -v err '%s' "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}." | ||
chadwhitacre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| printf -v cmd_exit '%s' "'$cmd' exited with status $retcode" | ||
| printf '%s\n%s\n' "$err" "$cmd_exit" | ||
| local stack_depth=${#FUNCNAME[@]} | ||
| local traceback="" | ||
| if [ $stack_depth -gt 2 ]; then | ||
| for ((i=$(($stack_depth - 1)),j=1;i>0;i--,j++)); do | ||
| local indent="$(yes a | head -$j | tr -d '\n')" | ||
| local src=${BASH_SOURCE[$i]} | ||
| local lineno=${BASH_LINENO[$i-1]} | ||
| local funcname=${FUNCNAME[$i]} | ||
| printf -v traceback '%s\n' "$traceback${indent//a/-}> $src:$funcname:$lineno" | ||
| done | ||
| fi | ||
| echo "$traceback" | ||
|
|
||
| if [ "$REPORT_ERRORS" == 1 ]; then | ||
| local traceback_hash=$(echo -n $traceback | docker run --rm busybox md5sum | cut -d' ' -f1) | ||
emmatyping marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| send_event "$traceback_hash" "$cmd_exit" | ||
| fi | ||
|
|
||
| if [[ -n "$MINIMIZE_DOWNTIME" ]]; then | ||
| echo "*NOT* cleaning up, to clean your environment run \"docker compose stop\"." | ||
|
|
@@ -30,6 +119,5 @@ cleanup () { | |
| $dc stop -t $STOP_TIMEOUT &> /dev/null | ||
| fi | ||
| } | ||
| trap_with_arg cleanup ERR INT TERM EXIT | ||
|
|
||
| echo "${_endgroup}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.