Skip to content

Commit

Permalink
Add deploy alert env var to fly + fix message prefix (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
walker-16 authored Jun 26, 2023
1 parent eae49e2 commit 1c67efc
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 50 deletions.
8 changes: 8 additions & 0 deletions common/client/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,11 @@ func (a Alert) toOpsgenieRequest() opsgenieAlert.CreateAlertRequest {
VisibleTo: visibleTo,
}
}

// GetMessagePrefix returns the alert message prefix.
func GetMessagePrefix(enviroment, p2pPNetwork string) string {
if enviroment == "production" {
return fmt.Sprintf("[%s-%s]", enviroment, p2pPNetwork)
}
return fmt.Sprintf("[%s]", enviroment)
}
26 changes: 20 additions & 6 deletions common/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sns v1.20.2
github.com/aws/aws-sdk-go-v2/service/sqs v1.20.2
github.com/go-redis/redis/v8 v8.11.5
github.com/gofiber/fiber/v2 v2.47.0
github.com/influxdata/influxdb-client-go/v2 v2.12.2
github.com/mr-tron/base58 v1.2.0
github.com/opsgenie/opsgenie-go-sdk-v2 v1.2.19
Expand All @@ -19,6 +20,7 @@ require (
)

require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
Expand All @@ -30,24 +32,36 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/ethereum/go-ethereum v1.10.21 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
github.com/hashicorp/go-retryablehttp v0.5.1 // indirect
github.com/holiman/uint256 v1.2.1 // indirect
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/tinylib/msgp v1.1.8 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.47.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.8.0 // indirect
)
77 changes: 70 additions & 7 deletions common/go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion deploy/common/env/production.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ INFLUX_TOKEN=
INFLUX_ORGANIZATION=
INFLUX_BUCKET_INFINITE=
INFLUX_BUCKET_30_DAYS=
INFLUX_BUCKET_24_HOURS=
INFLUX_BUCKET_24_HOURS=
ALERT_API_KEY=
3 changes: 2 additions & 1 deletion deploy/common/env/staging.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ INFLUX_TOKEN=
INFLUX_ORGANIZATION=
INFLUX_BUCKET_INFINITE=
INFLUX_BUCKET_30_DAYS=
INFLUX_BUCKET_24_HOURS=
INFLUX_BUCKET_24_HOURS=
ALERT_API_KEY=
3 changes: 2 additions & 1 deletion deploy/common/env/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ INFLUX_TOKEN=
INFLUX_ORGANIZATION=
INFLUX_BUCKET_INFINITE=
INFLUX_BUCKET_30_DAYS=
INFLUX_BUCKET_24_HOURS=
INFLUX_BUCKET_24_HOURS=
ALERT_API_KEY=
9 changes: 9 additions & 0 deletions deploy/common/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ metadata:
namespace: {{ .NAMESPACE }}
data:
token: {{ .INFLUX_TOKEN | b64enc }}
type: Opaque
---
kind: Secret
apiVersion: v1
metadata:
name: opsgenie
namespace: {{ .NAMESPACE }}
data:
api-key: {{ .ALERT_API_KEY | b64enc }}
type: Opaque
3 changes: 2 additions & 1 deletion deploy/fly/env/production.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ SQS_AWS_REGION=
P2P_NETWORK=mainnet
PPROF_ENABLED=false
MAX_HEALTH_TIME_SECONDS=90
AWS_IAM_ROLE=
AWS_IAM_ROLE=
ALERT_ENABLED=false
3 changes: 2 additions & 1 deletion deploy/fly/env/staging.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ SQS_AWS_REGION=
P2P_NETWORK=mainnet
PPROF_ENABLED=true
MAX_HEALTH_TIME_SECONDS=90
AWS_IAM_ROLE=
AWS_IAM_ROLE=
ALERT_ENABLED=false
3 changes: 2 additions & 1 deletion deploy/fly/env/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ SQS_AWS_REGION=
P2P_NETWORK=testnet
PPROF_ENABLED=false
MAX_HEALTH_TIME_SECONDS=300
AWS_IAM_ROLE=
AWS_IAM_ROLE=
ALERT_ENABLED=false
9 changes: 9 additions & 0 deletions deploy/fly/fly-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ spec:
key: redis-uri
- name: MAX_HEALTH_TIME_SECONDS
value: "{{ .MAX_HEALTH_TIME_SECONDS }}"
- name: ALERT_API_KEY
valueFrom:
secretKeyRef:
name: opsgenie
key: api-key
- name: ALERT_ENABLED
value: {{ .ALERT_ENABLED }}
- name: ENVIRONMENT
value: {{ .ENVIRONMENT }}
resources:
limits:
memory: {{ .RESOURCES_LIMITS_MEMORY }}
Expand Down
28 changes: 16 additions & 12 deletions fly/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/eko/gocache/v3 v3.1.2
github.com/ethereum/go-ethereum v1.10.21
github.com/go-redis/redis/v8 v8.11.5
github.com/gofiber/fiber/v2 v2.40.1
github.com/gofiber/fiber/v2 v2.47.0
github.com/joho/godotenv v1.4.0
github.com/libp2p/go-libp2p-core v0.20.0
github.com/patrickmn/go-cache v2.1.0+incompatible
Expand Down Expand Up @@ -42,6 +42,10 @@ require (
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opsgenie/opsgenie-go-sdk-v2 v1.2.19 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/tinylib/msgp v1.1.8 // indirect
)

require (
Expand All @@ -53,7 +57,7 @@ require (
github.com/CosmWasm/wasmvm v1.1.1 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/XiaoMi/pegasus-go-client v0.0.0-20210427083443-f3b6b08bc4c2 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/armon/go-metrics v0.4.0 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -142,7 +146,7 @@ require (
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/koron/go-ssdp v0.0.3 // indirect
github.com/lib/pq v1.10.6 // indirect
Expand All @@ -169,7 +173,7 @@ require (
github.com/marten-seemann/qtls-go1-19 v0.1.0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-pointer v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
Expand Down Expand Up @@ -235,7 +239,7 @@ require (
github.com/tendermint/tendermint v0.34.24 // indirect
github.com/tendermint/tm-db v0.6.7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.41.0 // indirect
github.com/valyala/fasthttp v1.47.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
Expand All @@ -250,15 +254,15 @@ require (
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.2.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/exp v0.0.0-20221110155412-d0897a79cd37 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 // indirect
google.golang.org/grpc v1.50.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit 1c67efc

Please sign in to comment.