mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmalert: fix nil map assignment (#4392)
The storage instance with nil map params was created for remote-read purposes. And before change7a9ae9de0d
this map was ignored in ApplyParams. Now, it started to be used and vmalert panics in runtime. The fix properly inits map for at `NewVMStorage` and verifies it is not nil on assignment in `ApplyParams`. Signed-off-by: hagen1778 <roman@victoriametrics.com> --------- Signed-off-by: hagen1778 <roman@victoriametrics.com> (cherry picked from commitde94812088
) Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
42d413edc0
commit
2831e6f9ae
2 changed files with 19 additions and 5 deletions
|
@ -29,7 +29,7 @@ type VMStorage struct {
|
||||||
|
|
||||||
// Clone makes clone of VMStorage, shares http client.
|
// Clone makes clone of VMStorage, shares http client.
|
||||||
func (s *VMStorage) Clone() *VMStorage {
|
func (s *VMStorage) Clone() *VMStorage {
|
||||||
return &VMStorage{
|
ns := &VMStorage{
|
||||||
c: s.c,
|
c: s.c,
|
||||||
authCfg: s.authCfg,
|
authCfg: s.authCfg,
|
||||||
datasourceURL: s.datasourceURL,
|
datasourceURL: s.datasourceURL,
|
||||||
|
@ -39,8 +39,15 @@ func (s *VMStorage) Clone() *VMStorage {
|
||||||
|
|
||||||
dataSourceType: s.dataSourceType,
|
dataSourceType: s.dataSourceType,
|
||||||
evaluationInterval: s.evaluationInterval,
|
evaluationInterval: s.evaluationInterval,
|
||||||
extraParams: s.extraParams,
|
|
||||||
|
// init map so it can be populated below
|
||||||
|
extraParams: url.Values{},
|
||||||
}
|
}
|
||||||
|
for k, v := range s.extraParams {
|
||||||
|
ns.extraParams[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
return ns
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyParams - changes given querier params.
|
// ApplyParams - changes given querier params.
|
||||||
|
@ -49,9 +56,14 @@ func (s *VMStorage) ApplyParams(params QuerierParams) *VMStorage {
|
||||||
s.dataSourceType = *params.DataSourceType
|
s.dataSourceType = *params.DataSourceType
|
||||||
}
|
}
|
||||||
s.evaluationInterval = params.EvaluationInterval
|
s.evaluationInterval = params.EvaluationInterval
|
||||||
for k, vl := range params.QueryParams {
|
if params.QueryParams != nil {
|
||||||
for _, v := range vl { // custom query params are prior to default ones
|
if s.extraParams == nil {
|
||||||
s.extraParams.Set(k, v)
|
s.extraParams = url.Values{}
|
||||||
|
}
|
||||||
|
for k, vl := range params.QueryParams {
|
||||||
|
for _, v := range vl { // custom query params are prior to default ones
|
||||||
|
s.extraParams.Set(k, v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
@ -72,6 +84,7 @@ func NewVMStorage(baseURL string, authCfg *promauth.Config, lookBack time.Durati
|
||||||
lookBack: lookBack,
|
lookBack: lookBack,
|
||||||
queryStep: queryStep,
|
queryStep: queryStep,
|
||||||
dataSourceType: NewPrometheusType(),
|
dataSourceType: NewPrometheusType(),
|
||||||
|
extraParams: url.Values{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
||||||
## v1.79.x long-time support release (LTS)
|
## v1.79.x long-time support release (LTS)
|
||||||
|
|
||||||
* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): Properly form path to static assets in WEB UI if `http.pathPrefix` set. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4349).
|
* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): Properly form path to static assets in WEB UI if `http.pathPrefix` set. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4349).
|
||||||
|
* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): Properly set datasource query params. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4340). Thanks to @gsakun for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4341).
|
||||||
|
|
||||||
## [v1.79.13](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.79.13)
|
## [v1.79.13](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.79.13)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue