Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit d2d4491

Browse files
authored
chore/deps: upgrade alertmanager package dependency, improve logs and tests (#63329)
Upgrades to our forked update v0.27.0, which matches the Alertmanager version we deploy: sourcegraph/alertmanager@3695ef8. Upon closer inspection I also realized I upgraded `prometheus/common` too far in https://github.com/sourcegraph/sourcegraph/pull/63328 - I've downgraded it to match the revision of Alertmanager we are using, while _also_ fulfilling the OpenFGA dependency https://github.com/sourcegraph/sourcegraph/pull/63329#discussion_r1646630946 for https://github.com/sourcegraph/sourcegraph/pull/63173 💀 The latest version of `prometheus/common` marshals configuration values that are unknown to our version of Alertmanager (v0.27.0) which rejects the generated configuration from `prom-wrapper`. I've also made a few updates to improve the testing and improve the prometheus and alertmanager output by forwarding them to differently-scoped loggers and crude conversion of the log levels: ![image](https://github.com/sourcegraph/sourcegraph/assets/23356519/d6e36a72-ad4f-4524-9061-89504776edfb) Related: https://github.com/sourcegraph/sourcegraph/pull/63171 Closes CORE-186 ## Test plan `sg start` and `sg run prometheus`, update some alerting configs in http://localhost:9090/alertmanager/#/status: <img src="https://github.com/sourcegraph/sourcegraph/assets/23356519/56cef853-ac39-4035-b584-57aec83e8301" width="30%"> In personal settings: ```json { "alerts.hideObservabilitySiteAlerts": false } ``` No banners show up indicating Prometheus is unhealthy.
1 parent 3a87f32 commit d2d4491

File tree

13 files changed

+311
-417
lines changed

13 files changed

+311
-417
lines changed

deps.bzl

Lines changed: 21 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,13 +1966,6 @@ def go_dependencies():
19661966
sum = "h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=",
19671967
version = "v0.3.5",
19681968
)
1969-
go_repository(
1970-
name = "com_github_globalsign_mgo",
1971-
build_file_proto_mode = "disable_global",
1972-
importpath = "github.com/globalsign/mgo",
1973-
sum = "h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is=",
1974-
version = "v0.0.0-20181015135952-eeefdecb41b8",
1975-
)
19761969
go_repository(
19771970
name = "com_github_go_chi_chi_v5",
19781971
build_file_proto_mode = "disable_global",
@@ -2323,90 +2316,6 @@ def go_dependencies():
23232316
sum = "h1:7M2kwOsc//9VeeFiPtf+uSJlVpU66x9Ba5+8XK7/TDg=",
23242317
version = "v1.0.3",
23252318
)
2326-
go_repository(
2327-
name = "com_github_gobuffalo_attrs",
2328-
build_file_proto_mode = "disable_global",
2329-
importpath = "github.com/gobuffalo/attrs",
2330-
sum = "h1:hSkbZ9XSyjyBirMeqSqUrK+9HboWrweVlzRNqoBi2d4=",
2331-
version = "v0.0.0-20190224210810-a9411de4debd",
2332-
)
2333-
go_repository(
2334-
name = "com_github_gobuffalo_depgen",
2335-
build_file_proto_mode = "disable_global",
2336-
importpath = "github.com/gobuffalo/depgen",
2337-
sum = "h1:31atYa/UW9V5q8vMJ+W6wd64OaaTHUrCUXER358zLM4=",
2338-
version = "v0.1.0",
2339-
)
2340-
go_repository(
2341-
name = "com_github_gobuffalo_envy",
2342-
build_file_proto_mode = "disable_global",
2343-
importpath = "github.com/gobuffalo/envy",
2344-
sum = "h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU=",
2345-
version = "v1.7.0",
2346-
)
2347-
go_repository(
2348-
name = "com_github_gobuffalo_flect",
2349-
build_file_proto_mode = "disable_global",
2350-
importpath = "github.com/gobuffalo/flect",
2351-
sum = "h1:3GQ53z7E3o00C/yy7Ko8VXqQXoJGLkrTQCLTF1EjoXU=",
2352-
version = "v0.1.3",
2353-
)
2354-
go_repository(
2355-
name = "com_github_gobuffalo_genny",
2356-
build_file_proto_mode = "disable_global",
2357-
importpath = "github.com/gobuffalo/genny",
2358-
sum = "h1:iQ0D6SpNXIxu52WESsD+KoQ7af2e3nCfnSBoSF/hKe0=",
2359-
version = "v0.1.1",
2360-
)
2361-
go_repository(
2362-
name = "com_github_gobuffalo_gitgen",
2363-
build_file_proto_mode = "disable_global",
2364-
importpath = "github.com/gobuffalo/gitgen",
2365-
sum = "h1:mSVZ4vj4khv+oThUfS+SQU3UuFIZ5Zo6UNcvK8E8Mz8=",
2366-
version = "v0.0.0-20190315122116-cc086187d211",
2367-
)
2368-
go_repository(
2369-
name = "com_github_gobuffalo_gogen",
2370-
build_file_proto_mode = "disable_global",
2371-
importpath = "github.com/gobuffalo/gogen",
2372-
sum = "h1:dLg+zb+uOyd/mKeQUYIbwbNmfRsr9hd/WtYWepmayhI=",
2373-
version = "v0.1.1",
2374-
)
2375-
go_repository(
2376-
name = "com_github_gobuffalo_logger",
2377-
build_file_proto_mode = "disable_global",
2378-
importpath = "github.com/gobuffalo/logger",
2379-
sum = "h1:8thhT+kUJMTMy3HlX4+y9Da+BNJck+p109tqqKp7WDs=",
2380-
version = "v0.0.0-20190315122211-86e12af44bc2",
2381-
)
2382-
go_repository(
2383-
name = "com_github_gobuffalo_mapi",
2384-
build_file_proto_mode = "disable_global",
2385-
importpath = "github.com/gobuffalo/mapi",
2386-
sum = "h1:fq9WcL1BYrm36SzK6+aAnZ8hcp+SrmnDyAxhNx8dvJk=",
2387-
version = "v1.0.2",
2388-
)
2389-
go_repository(
2390-
name = "com_github_gobuffalo_packd",
2391-
build_file_proto_mode = "disable_global",
2392-
importpath = "github.com/gobuffalo/packd",
2393-
sum = "h1:4sGKOD8yaYJ+dek1FDkwcxCHA40M4kfKgFHx8N2kwbU=",
2394-
version = "v0.1.0",
2395-
)
2396-
go_repository(
2397-
name = "com_github_gobuffalo_packr_v2",
2398-
build_file_proto_mode = "disable_global",
2399-
importpath = "github.com/gobuffalo/packr/v2",
2400-
sum = "h1:Ir9W9XIm9j7bhhkKE9cokvtTl1vBm62A/fene/ZCj6A=",
2401-
version = "v2.2.0",
2402-
)
2403-
go_repository(
2404-
name = "com_github_gobuffalo_syncx",
2405-
build_file_proto_mode = "disable_global",
2406-
importpath = "github.com/gobuffalo/syncx",
2407-
sum = "h1:tpom+2CJmpzAWj5/VEHync2rJGi+epHNIeRSWjzGA+4=",
2408-
version = "v0.0.0-20190224160051-33c29581e754",
2409-
)
24102319
go_repository(
24112320
name = "com_github_gobwas_glob",
24122321
build_file_proto_mode = "disable_global",
@@ -3135,8 +3044,8 @@ def go_dependencies():
31353044
name = "com_github_hashicorp_go_sockaddr",
31363045
build_file_proto_mode = "disable_global",
31373046
importpath = "github.com/hashicorp/go-sockaddr",
3138-
sum = "h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc=",
3139-
version = "v1.0.2",
3047+
sum = "h1:RSG8rKU28VTUTvEKghe5gIhIQpv8evvNpnDEyqO4u9I=",
3048+
version = "v1.0.6",
31403049
)
31413050
go_repository(
31423051
name = "com_github_hashicorp_go_syslog",
@@ -3212,8 +3121,8 @@ def go_dependencies():
32123121
name = "com_github_hashicorp_memberlist",
32133122
build_file_proto_mode = "disable_global",
32143123
importpath = "github.com/hashicorp/memberlist",
3215-
sum = "h1:8+567mCcFDnS5ADl7lrpxPMWiFCElyUEeW0gtj34fMA=",
3216-
version = "v0.3.0",
3124+
sum = "h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR/prTM=",
3125+
version = "v0.5.0",
32173126
)
32183127
go_repository(
32193128
name = "com_github_hashicorp_nomad_api",
@@ -3747,13 +3656,6 @@ def go_dependencies():
37473656
sum = "h1:ND0eDpwiUFIrm/n1ehxUyh/XNGs9zkYrLxtGqENSalY=",
37483657
version = "v1.1.8",
37493658
)
3750-
go_repository(
3751-
name = "com_github_karrick_godirwalk",
3752-
build_file_proto_mode = "disable_global",
3753-
importpath = "github.com/karrick/godirwalk",
3754-
sum = "h1:lOpSw2vJP0y5eLBW906QwKsUK/fe/QDyoqM5rnnuPDY=",
3755-
version = "v1.10.3",
3756-
)
37573659
go_repository(
37583660
name = "com_github_kataras_blocks",
37593661
build_file_proto_mode = "disable_global",
@@ -4132,20 +4034,6 @@ def go_dependencies():
41324034
sum = "h1:rlCHh70XXXv7toz95ajQWOWQnN4WNLt0TdpZYIR/J6A=",
41334035
version = "v2.0.1",
41344036
)
4135-
go_repository(
4136-
name = "com_github_markbates_oncer",
4137-
build_file_proto_mode = "disable_global",
4138-
importpath = "github.com/markbates/oncer",
4139-
sum = "h1:JgVTCPf0uBVcUSWpyXmGpgOc62nK5HWUBKAGc3Qqa5k=",
4140-
version = "v0.0.0-20181203154359-bf2de49a0be2",
4141-
)
4142-
go_repository(
4143-
name = "com_github_markbates_safe",
4144-
build_file_proto_mode = "disable_global",
4145-
importpath = "github.com/markbates/safe",
4146-
sum = "h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=",
4147-
version = "v1.0.1",
4148-
)
41494037
go_repository(
41504038
name = "com_github_masterminds_goutils",
41514039
build_file_proto_mode = "disable_global",
@@ -4779,13 +4667,6 @@ def go_dependencies():
47794667
sum = "h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=",
47804668
version = "v0.1.0",
47814669
)
4782-
go_repository(
4783-
name = "com_github_pborman_uuid",
4784-
build_file_proto_mode = "disable_global",
4785-
importpath = "github.com/pborman/uuid",
4786-
sum = "h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=",
4787-
version = "v1.2.0",
4788-
)
47894670
go_repository(
47904671
name = "com_github_pelletier_go_toml",
47914672
build_file_proto_mode = "disable_global",
@@ -4952,15 +4833,15 @@ def go_dependencies():
49524833
build_file_proto_mode = "disable_global",
49534834
importpath = "github.com/prometheus/alertmanager",
49544835
replace = "github.com/sourcegraph/alertmanager",
4955-
sum = "h1:Mlytsllyx6d1eaKXt8urXX0YjP5Tq4UGV+BfL6Yc1aQ=",
4956-
version = "v0.21.1-0.20211110092431-863f5b1ee51b",
4836+
sum = "h1:nculomxxOp6cfc6xYjff96kHJ1Lu2Gl/4uWj5lr/wmg=",
4837+
version = "v0.24.1-0.20240619011019-3695ef8bcc9a",
49574838
)
49584839
go_repository(
49594840
name = "com_github_prometheus_client_golang",
49604841
build_file_proto_mode = "disable_global",
49614842
importpath = "github.com/prometheus/client_golang",
4962-
sum = "h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=",
4963-
version = "v1.19.1",
4843+
sum = "h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=",
4844+
version = "v1.19.0",
49644845
)
49654846
go_repository(
49664847
name = "com_github_prometheus_client_model",
@@ -4973,8 +4854,8 @@ def go_dependencies():
49734854
name = "com_github_prometheus_common",
49744855
build_file_proto_mode = "disable_global",
49754856
importpath = "github.com/prometheus/common",
4976-
sum = "h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8=",
4977-
version = "v0.54.0",
4857+
sum = "h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=",
4858+
version = "v0.48.0",
49784859
)
49794860
go_repository(
49804861
name = "com_github_prometheus_common_assets",
@@ -4994,8 +4875,8 @@ def go_dependencies():
49944875
name = "com_github_prometheus_exporter_toolkit",
49954876
build_file_proto_mode = "disable_global",
49964877
importpath = "github.com/prometheus/exporter-toolkit",
4997-
sum = "h1:sbJAfBXQFkG6sUkbwBun8MNdzW9+wd5YfPYofbmj0YM=",
4998-
version = "v0.8.2",
4878+
sum = "h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g=",
4879+
version = "v0.11.0",
49994880
)
50004881
go_repository(
50014882
name = "com_github_prometheus_procfs",
@@ -6042,8 +5923,8 @@ def go_dependencies():
60425923
name = "com_github_ugorji_go",
60435924
build_file_proto_mode = "disable_global",
60445925
importpath = "github.com/ugorji/go",
6045-
sum = "h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=",
6046-
version = "v1.1.7",
5926+
sum = "h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=",
5927+
version = "v1.1.4",
60475928
)
60485929
go_repository(
60495930
name = "com_github_ugorji_go_codec",
@@ -6101,13 +5982,6 @@ def go_dependencies():
61015982
sum = "h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=",
61025983
version = "v0.11.5",
61035984
)
6104-
go_repository(
6105-
name = "com_github_vektah_gqlparser",
6106-
build_file_proto_mode = "disable_global",
6107-
importpath = "github.com/vektah/gqlparser",
6108-
sum = "h1:ZsyLGn7/7jDNI+y4SEhI4yAxRChlv15pUHMjijT+e68=",
6109-
version = "v1.1.2",
6110-
)
61115985
go_repository(
61125986
name = "com_github_vektah_gqlparser_v2",
61135987
build_file_proto_mode = "disable_global",
@@ -6192,20 +6066,6 @@ def go_dependencies():
61926066
sum = "h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=",
61936067
version = "v1.0.4",
61946068
)
6195-
go_repository(
6196-
name = "com_github_xdg_scram",
6197-
build_file_proto_mode = "disable_global",
6198-
importpath = "github.com/xdg/scram",
6199-
sum = "h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk=",
6200-
version = "v0.0.0-20180814205039-7eeb5667e42c",
6201-
)
6202-
go_repository(
6203-
name = "com_github_xdg_stringprep",
6204-
build_file_proto_mode = "disable_global",
6205-
importpath = "github.com/xdg/stringprep",
6206-
sum = "h1:n+nNi93yXLkJvKwXNP9d55HC7lGK4H/SRcwB5IaUZLo=",
6207-
version = "v0.0.0-20180714160509-73f8eece6fdc",
6208-
)
62096069
go_repository(
62106070
name = "com_github_xeipuuv_gojsonpointer",
62116071
build_file_proto_mode = "disable_global",
@@ -7333,20 +7193,6 @@ def go_dependencies():
73337193
sum = "h1:qEzJlIDmG9q5VO0M/o8tGS65QMHMS1w01TQJB1VPJ4U=",
73347194
version = "v2.6.1",
73357195
)
7336-
go_repository(
7337-
name = "in_gopkg_go_playground_assert_v1",
7338-
build_file_proto_mode = "disable_global",
7339-
importpath = "gopkg.in/go-playground/assert.v1",
7340-
sum = "h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=",
7341-
version = "v1.2.1",
7342-
)
7343-
go_repository(
7344-
name = "in_gopkg_go_playground_validator_v9",
7345-
build_file_proto_mode = "disable_global",
7346-
importpath = "gopkg.in/go-playground/validator.v9",
7347-
sum = "h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc=",
7348-
version = "v9.29.1",
7349-
)
73507196
go_repository(
73517197
name = "in_gopkg_inconshreveable_log15_v2",
73527198
build_file_proto_mode = "disable_global",
@@ -7390,6 +7236,13 @@ def go_dependencies():
73907236
sum = "h1:nt80fvSDlhKWQgSWyHyy5CfmlQr+asih51R8PTWNKKs=",
73917237
version = "v2.6.3",
73927238
)
7239+
go_repository(
7240+
name = "in_gopkg_telebot_v3",
7241+
build_file_proto_mode = "disable_global",
7242+
importpath = "gopkg.in/telebot.v3",
7243+
sum = "h1:3I4LohaAyJBiivGmkfB+CiVu7QFOWkuZ4+KHgO/G3rs=",
7244+
version = "v3.2.1",
7245+
)
73937246
go_repository(
73947247
name = "in_gopkg_tomb_v1",
73957248
build_file_proto_mode = "disable_global",

docker-images/prometheus/cmd/prom-wrapper/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ go_library(
3636
"@com_github_prometheus_common//config",
3737
"@com_github_prometheus_common//model",
3838
"@com_github_sourcegraph_log//:log",
39+
"@dev_bobheadxi_go_streamline//streamexec",
3940
"@in_gopkg_yaml_v2//:yaml_v2",
41+
"@org_golang_x_exp//maps",
4042
],
4143
)
4244

@@ -65,6 +67,9 @@ go_test(
6567
deps = [
6668
"//internal/version",
6769
"//schema",
70+
"@com_github_hexops_autogold_v2//:autogold",
6871
"@com_github_prometheus_alertmanager//config",
72+
"@com_github_stretchr_testify//require",
73+
"@in_gopkg_yaml_v2//:yaml_v2",
6974
],
7075
)

docker-images/prometheus/cmd/prom-wrapper/alertmanager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import (
1212
"github.com/prometheus/alertmanager/api/v2/client/general"
1313
amconfig "github.com/prometheus/alertmanager/config"
1414
"github.com/prometheus/common/model"
15-
"gopkg.in/yaml.v2"
15+
"gopkg.in/yaml.v2" // same as used in alertmanager
1616

1717
"github.com/sourcegraph/sourcegraph/lib/errors"
1818
)
1919

2020
// Prefix to serve alertmanager on. If you change this, make sure you update prometheus.yml as well
2121
const alertmanagerPathPrefix = "alertmanager"
2222

23-
func waitForAlertmanager(ctx context.Context, alertmanager *amclient.Alertmanager) error {
23+
func waitForAlertmanager(ctx context.Context, alertmanager *amclient.AlertmanagerAPI) error {
2424
ping := func(ctx context.Context) error {
2525
resp, err := alertmanager.General.GetStatus(&general.GetStatusParams{Context: ctx})
2626
if err != nil {

docker-images/prometheus/cmd/prom-wrapper/change.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
type ChangeContext struct {
2424
AMConfig *amconfig.Config // refer to https://prometheus.io/docs/alerting/latest/configuration/
25-
AMClient *amclient.Alertmanager
25+
AMClient *amclient.AlertmanagerAPI
2626
}
2727

2828
// ChangeResult indicates output from a Change

0 commit comments

Comments
 (0)