Skip to content
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

Release 0.21.1 #929

Merged
merged 2 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.21.1 / 2022-06-17

* [BUGFIX] Fix a data race in HTTP probes. #929

## 0.21.0 / 2022-05-30

This Prometheus release is built with go1.18, which contains two noticeable
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.21.0
0.21.1
12 changes: 10 additions & 2 deletions prober/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ import (
"github.com/prometheus/blackbox_exporter/config"
)

var caser = cases.Title(language.Und)

func matchRegularExpressions(reader io.Reader, httpConfig config.HTTPProbe, logger log.Logger) bool {
body, err := ioutil.ReadAll(reader)
if err != nil {
Expand Down Expand Up @@ -342,6 +340,16 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr
return false
}

// Do not move the following variable to global scope. The cases.Caser returned by
// calling cases.Title *cannot* be shared among goroutines. This might happen when
// Prometheus tries to scrape multiple targets at the same time. From the docs:
//
// A Caser may be stateful and should therefore not be shared between goroutines.
//
// Issue: https://github.com/prometheus/blackbox_exporter/issues/922

caser := cases.Title(language.Und)

httpClientConfig := module.HTTP.HTTPClientConfig
if len(httpClientConfig.TLSConfig.ServerName) == 0 {
// If there is no `server_name` in tls_config, use
Expand Down
3 changes: 3 additions & 0 deletions prober/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
pconfig "github.com/prometheus/common/config"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/prometheus/blackbox_exporter/config"
)
Expand Down Expand Up @@ -1068,6 +1070,7 @@ func TestHTTPHeaders(t *testing.T) {
"Accept-Language": "en-US",
}
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
caser := cases.Title(language.Und)
for key, value := range headers {
if caser.String(key) == "Host" {
if r.Host != value {
Expand Down