-
Notifications
You must be signed in to change notification settings - Fork 5
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
Deploy Bootstrap and add Metrics #38
Changes from all commits
e0d1184
3e8a67a
31d6a22
05a4185
7f5cfdb
f6c17c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely doesn't need to be done in this PR, but would it be easier for maintenance for this to be done through a separate little rust binary in this repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ya i can do that. what is the benefit? Just less bash code? and since it doesn't change we can just use a binary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I was wondering where we draw the line between RIIR and Keep It In Bash (KIIB??)... This could definitely stay as a bash script, which is why my comment was a question. Feel free to disregard! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh yes fair enough! i do like the idea of putting it in rust just to keep it somewhat uniform. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
here=$(dirname "$0") | ||
|
||
# https://gist.github.com/cdown/1163649 | ||
urlencode() { | ||
declare s="$1" | ||
declare l=$((${#s} - 1)) | ||
for i in $(seq 0 $l); do | ||
declare c="${s:$i:1}" | ||
case $c in | ||
[a-zA-Z0-9.~_-]) | ||
echo -n "$c" | ||
;; | ||
*) | ||
printf '%%%02X' "'$c" | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
usage() { | ||
exitcode=0 | ||
if [[ -n "$1" ]]; then | ||
exitcode=1 | ||
echo "Error: $*" | ||
fi | ||
cat <<EOF | ||
usage: $0 [-e] [-d] [-c database_name] [username] | ||
|
||
Creates a testnet dev metrics database | ||
|
||
username InfluxDB user with access to create a new database | ||
-c Manually specify a database to create, rather than read from config file | ||
-d Delete the database instead of creating it | ||
-e Assume database already exists and SOLANA_METRICS_CONFIG is | ||
defined in the environment already | ||
|
||
EOF | ||
exit $exitcode | ||
} | ||
|
||
useEnv=false | ||
delete=false | ||
createWithoutConfig=false | ||
host="https://internal-metrics.solana.com:8086" | ||
while getopts ":hdec:" opt; do | ||
case $opt in | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
c) | ||
createWithoutConfig=true | ||
netBasename=$OPTARG | ||
;; | ||
d) | ||
delete=true | ||
;; | ||
e) | ||
useEnv=true | ||
;; | ||
*) | ||
usage "unhandled option: $OPTARG" | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND - 1)) | ||
|
||
if $useEnv; then | ||
[[ -n $SOLANA_METRICS_CONFIG ]] || | ||
usage "SOLANA_METRICS_CONFIG is not defined in the environment" | ||
else | ||
username=$1 | ||
[[ -n "$username" ]] || usage "username not specified" | ||
|
||
read -rs -p "InfluxDB password for $username: " password | ||
[[ -n $password ]] || { echo "Password not specified"; exit 1; } | ||
echo | ||
|
||
password="$(urlencode "$password")" | ||
|
||
query() { | ||
echo "$*" | ||
set -x | ||
curl -XPOST \ | ||
"$host/query?u=${username}&p=${password}" \ | ||
--data-urlencode "q=$*" | ||
} | ||
|
||
query "DROP DATABASE \"$netBasename\"" | ||
! $delete || exit 0 | ||
query "CREATE DATABASE \"$netBasename\"" | ||
query "ALTER RETENTION POLICY autogen ON \"$netBasename\" DURATION 7d" | ||
query "GRANT READ ON \"$netBasename\" TO \"ro\"" | ||
query "GRANT WRITE ON \"$netBasename\" TO \"scratch_writer\"" | ||
|
||
SOLANA_METRICS_CONFIG="host=$host,db=$netBasename,u=scratch_writer,p=topsecret" | ||
fi | ||
|
||
exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit typo