mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
feat: add timeout field in Webhook receiver
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com> Co-Authored-by Nutmos <nutmos@users.noreply.github.com>
This commit is contained in:
parent
ff2afc3b93
commit
450a1396e3
6 changed files with 50 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
* [FEATURE] Add `keepIdentifyingResourceAttributes` field in OTLPConfig for `Prometheus` and `PrometheusAgent` CRDs. #7240
|
||||
* [FEATURE] Add `fallbackScrapeProtocol` field to ScrapeClass for `Prometheus` and `PrometheusAgent` CRDs. #7288
|
||||
* [FEATURE] Support `MSTeamsV2Config` receiver in Alertmanager configuration Secret. #7296
|
||||
* [FEATURE] Add `Timeout` field in Webhook receiver in Alertmanager configuration Secret. #7312
|
||||
* [FEATURE] Add `scrapeFailureLogFile` field to the Prometheus and PrometheusAgent CRDs. #7038 #7311
|
||||
* [BUGFIX] Validate respective api URL field in PagerDutyConfigs, DiscordConfigs, SlackConfigs and WebhookConfigs in AlertManagerConfig CRD. #6585
|
||||
|
||||
|
|
|
@ -2240,6 +2240,12 @@ func (whc *webhookConfig) sanitize(amVersion semver.Version, logger *slog.Logger
|
|||
whc.URLFile = ""
|
||||
}
|
||||
|
||||
if whc.Timeout != nil && amVersion.LT(semver.MustParse("0.28.0")) {
|
||||
msg := "'timeout' supported in Alertmanager >= 0.28.0 only - dropping field from provided config"
|
||||
logger.Warn(msg, "current_version", amVersion.String())
|
||||
whc.Timeout = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -3649,6 +3649,38 @@ func TestSanitizeWebhookConfig(t *testing.T) {
|
|||
},
|
||||
golden: "test_url_takes_precedence_in_webhook_config.golden",
|
||||
},
|
||||
{
|
||||
name: "Test timeout is dropped in webhook config for unsupported versions",
|
||||
againstVersion: semver.Version{Major: 0, Minor: 26},
|
||||
in: &alertmanagerConfig{
|
||||
Receivers: []*receiver{
|
||||
{
|
||||
WebhookConfigs: []*webhookConfig{
|
||||
{
|
||||
Timeout: ptr.To(model.Duration(time.Minute)),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
golden: "test_webhook_timeout_is_dropped_in_webhook_config_for_unsupported_versions.golden",
|
||||
},
|
||||
{
|
||||
name: "Test timeout is added in webhook config for supported versions",
|
||||
againstVersion: semver.Version{Major: 0, Minor: 28},
|
||||
in: &alertmanagerConfig{
|
||||
Receivers: []*receiver{
|
||||
{
|
||||
WebhookConfigs: []*webhookConfig{
|
||||
{
|
||||
Timeout: ptr.To(model.Duration(time.Minute)),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
golden: "test_webhook_timeout_is_added_in_webhook_config_for_supported_versions.golden",
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := tc.in.sanitize(tc.againstVersion, logger)
|
||||
|
|
5
pkg/alertmanager/testdata/test_webhook_timeout_is_added_in_webhook_config_for_supported_versions.golden
generated
vendored
Normal file
5
pkg/alertmanager/testdata/test_webhook_timeout_is_added_in_webhook_config_for_supported_versions.golden
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
receivers:
|
||||
- name: ""
|
||||
webhook_configs:
|
||||
- timeout: 1m
|
||||
templates: []
|
5
pkg/alertmanager/testdata/test_webhook_timeout_is_dropped_in_webhook_config_for_unsupported_versions.golden
generated
vendored
Normal file
5
pkg/alertmanager/testdata/test_webhook_timeout_is_dropped_in_webhook_config_for_unsupported_versions.golden
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
receivers:
|
||||
- name: ""
|
||||
webhook_configs:
|
||||
- {}
|
||||
templates: []
|
|
@ -120,6 +120,7 @@ type webhookConfig struct {
|
|||
URLFile string `yaml:"url_file,omitempty" json:"url_file,omitempty"`
|
||||
HTTPConfig *httpClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`
|
||||
MaxAlerts int32 `yaml:"max_alerts,omitempty" json:"max_alerts,omitempty"`
|
||||
Timeout *model.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
type pagerdutyConfig struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue