fix(relay): Fix failed to write credentials (#450)
This commit is contained in:
parent
d31f46831e
commit
ecccb211aa
@ -178,11 +178,11 @@ services:
|
|||||||
relay:
|
relay:
|
||||||
<< : *restart_policy
|
<< : *restart_policy
|
||||||
image: "us.gcr.io/sentryio/relay:latest"
|
image: "us.gcr.io/sentryio/relay:latest"
|
||||||
command: 'run --config /etc/relay'
|
|
||||||
volumes:
|
volumes:
|
||||||
- type: bind
|
- type: bind
|
||||||
|
read_only: true
|
||||||
source: ./relay
|
source: ./relay
|
||||||
target: /etc/relay
|
target: /work/.relay
|
||||||
depends_on:
|
depends_on:
|
||||||
- kafka
|
- kafka
|
||||||
- redis
|
- redis
|
||||||
|
17
install.sh
17
install.sh
@ -178,9 +178,20 @@ if [ ! -f "$RELAY_CREDENTIALS_JSON" ]; then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Generating Relay credentials..."
|
echo "Generating Relay credentials..."
|
||||||
|
|
||||||
$dcr --user $(id -u) relay --config /etc/relay credentials generate --overwrite
|
# We need the ugly hack below as `relay generate credentials` tries to read the config and the credentials
|
||||||
chmod a+r $RELAY_CREDENTIALS_JSON
|
# even with the `--stdout` and `--overwrite` flags and then errors out when the credentials file exists but
|
||||||
|
# not valid JSON.
|
||||||
|
$dcr --no-deps --entrypoint /bin/bash relay -c "cp /work/.relay/config.yml /tmp/config.yml && /bin/relay --config /tmp credentials generate > /dev/null && cat /tmp/credentials.json" > "$RELAY_CREDENTIALS_JSON"
|
||||||
CREDENTIALS=$(sed -n 's/^.*"public_key"[[:space:]]*:[[:space:]]*"\([a-zA-Z0-9_-]\{1,\}\)".*$/\1/p' "$RELAY_CREDENTIALS_JSON")
|
CREDENTIALS=$(sed -n 's/^.*"public_key"[[:space:]]*:[[:space:]]*"\([a-zA-Z0-9_-]\{1,\}\)".*$/\1/p' "$RELAY_CREDENTIALS_JSON")
|
||||||
|
if [ -z "$CREDENTIALS" ]; then
|
||||||
|
>&2 echo "FAIL: Cannot read credentials back from $RELAY_CREDENTIALS_JSON."
|
||||||
|
>&2 echo " Please ensure this file is readable and contains valid credentials."
|
||||||
|
>&2 echo ""
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Relay credentials written to $RELAY_CREDENTIALS_JSON"
|
||||||
|
fi
|
||||||
|
|
||||||
CREDENTIALS="SENTRY_RELAY_WHITELIST_PK = [\"$CREDENTIALS\"]"
|
CREDENTIALS="SENTRY_RELAY_WHITELIST_PK = [\"$CREDENTIALS\"]"
|
||||||
|
|
||||||
if grep -xq SENTRY_RELAY_WHITELIST_PK "$SENTRY_CONFIG_PY"; then
|
if grep -xq SENTRY_RELAY_WHITELIST_PK "$SENTRY_CONFIG_PY"; then
|
||||||
@ -193,6 +204,8 @@ if [ ! -f "$RELAY_CREDENTIALS_JSON" ]; then
|
|||||||
|
|
||||||
echo "" >> "$SENTRY_CONFIG_PY"
|
echo "" >> "$SENTRY_CONFIG_PY"
|
||||||
echo "$CREDENTIALS" >> "$SENTRY_CONFIG_PY"
|
echo "$CREDENTIALS" >> "$SENTRY_CONFIG_PY"
|
||||||
|
echo "Relay public key written to $SENTRY_CONFIG_PY"
|
||||||
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
@ -3,9 +3,8 @@ relay:
|
|||||||
upstream: "http://web:9000/"
|
upstream: "http://web:9000/"
|
||||||
host: 0.0.0.0
|
host: 0.0.0.0
|
||||||
port: 3000
|
port: 3000
|
||||||
#logging:
|
logging:
|
||||||
# # Available logging levels: TRACE, DEBUG, INFO, WARN, ERROR
|
level: WARN
|
||||||
# level: WARN
|
|
||||||
processing:
|
processing:
|
||||||
enabled: true
|
enabled: true
|
||||||
kafka_config:
|
kafka_config:
|
||||||
|
Reference in New Issue
Block a user