fix: change the default max retry count for webhook job to 3 (#18392)

Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
Chlins Zhang 2023-03-22 17:36:50 +08:00 committed by GitHub
parent c1d297b015
commit 395ae77d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 12 deletions

View File

@ -117,7 +117,7 @@ jobservice:
notification:
# Maximum retry count for webhook job
webhook_job_max_retry: 10
webhook_job_max_retry: 3
# HTTP client timeout for webhook job
webhook_job_http_client_timeout: 3 #seconds

View File

@ -263,7 +263,7 @@ notification:
webhook_job_http_client_timeout: 3 #seconds
{% endif %}
{% else %}
webhook_job_max_retry: 10
webhook_job_max_retry: 3
# HTTP client timeout for webhook job
webhook_job_http_client_timeout: 3 #seconds
{% endif %}

View File

@ -22,9 +22,8 @@ type SlackJob struct {
// MaxFails returns that how many times this job can fail.
func (sj *SlackJob) MaxFails() (result uint) {
// Default max fails count is 10, and its max retry interval is around 3h
// Large enough to ensure most situations can notify successfully
result = 10
// Default max fails count is 3
result = 3
if maxFails, exist := os.LookupEnv(maxFails); exist {
mf, err := strconv.ParseUint(maxFails, 10, 32)
if err != nil {

View File

@ -15,7 +15,7 @@ import (
func TestSlackJobMaxFails(t *testing.T) {
rep := &SlackJob{}
t.Run("default max fails", func(t *testing.T) {
assert.Equal(t, uint(10), rep.MaxFails())
assert.Equal(t, uint(3), rep.MaxFails())
})
t.Run("user defined max fails", func(t *testing.T) {
@ -25,7 +25,7 @@ func TestSlackJobMaxFails(t *testing.T) {
t.Run("user defined wrong max fails", func(t *testing.T) {
t.Setenv(maxFails, "abc")
assert.Equal(t, uint(10), rep.MaxFails())
assert.Equal(t, uint(3), rep.MaxFails())
})
}

View File

@ -22,9 +22,8 @@ type WebhookJob struct {
// MaxFails returns that how many times this job can fail, get this value from ctx.
func (wj *WebhookJob) MaxFails() (result uint) {
// Default max fails count is 10, and its max retry interval is around 3h
// Large enough to ensure most situations can notify successfully
result = 10
// Default max fails count is 3
result = 3
if maxFails, exist := os.LookupEnv(maxFails); exist {
mf, err := strconv.ParseUint(maxFails, 10, 32)
if err != nil {

View File

@ -14,7 +14,7 @@ import (
func TestMaxFails(t *testing.T) {
rep := &WebhookJob{}
t.Run("default max fails", func(t *testing.T) {
assert.Equal(t, uint(10), rep.MaxFails())
assert.Equal(t, uint(3), rep.MaxFails())
})
t.Run("user defined max fails", func(t *testing.T) {
@ -24,7 +24,7 @@ func TestMaxFails(t *testing.T) {
t.Run("user defined wrong max fails", func(t *testing.T) {
t.Setenv(maxFails, "abc")
assert.Equal(t, uint(10), rep.MaxFails())
assert.Equal(t, uint(3), rep.MaxFails())
})
}