mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 17:25:32 +00:00
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:
parent
c1d297b015
commit
395ae77d64
|
@ -117,7 +117,7 @@ jobservice:
|
||||||
|
|
||||||
notification:
|
notification:
|
||||||
# Maximum retry count for webhook job
|
# Maximum retry count for webhook job
|
||||||
webhook_job_max_retry: 10
|
webhook_job_max_retry: 3
|
||||||
# HTTP client timeout for webhook job
|
# HTTP client timeout for webhook job
|
||||||
webhook_job_http_client_timeout: 3 #seconds
|
webhook_job_http_client_timeout: 3 #seconds
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ notification:
|
||||||
webhook_job_http_client_timeout: 3 #seconds
|
webhook_job_http_client_timeout: 3 #seconds
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
webhook_job_max_retry: 10
|
webhook_job_max_retry: 3
|
||||||
# HTTP client timeout for webhook job
|
# HTTP client timeout for webhook job
|
||||||
webhook_job_http_client_timeout: 3 #seconds
|
webhook_job_http_client_timeout: 3 #seconds
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -22,9 +22,8 @@ type SlackJob struct {
|
||||||
|
|
||||||
// MaxFails returns that how many times this job can fail.
|
// MaxFails returns that how many times this job can fail.
|
||||||
func (sj *SlackJob) MaxFails() (result uint) {
|
func (sj *SlackJob) MaxFails() (result uint) {
|
||||||
// Default max fails count is 10, and its max retry interval is around 3h
|
// Default max fails count is 3
|
||||||
// Large enough to ensure most situations can notify successfully
|
result = 3
|
||||||
result = 10
|
|
||||||
if maxFails, exist := os.LookupEnv(maxFails); exist {
|
if maxFails, exist := os.LookupEnv(maxFails); exist {
|
||||||
mf, err := strconv.ParseUint(maxFails, 10, 32)
|
mf, err := strconv.ParseUint(maxFails, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
func TestSlackJobMaxFails(t *testing.T) {
|
func TestSlackJobMaxFails(t *testing.T) {
|
||||||
rep := &SlackJob{}
|
rep := &SlackJob{}
|
||||||
t.Run("default max fails", func(t *testing.T) {
|
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) {
|
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.Run("user defined wrong max fails", func(t *testing.T) {
|
||||||
t.Setenv(maxFails, "abc")
|
t.Setenv(maxFails, "abc")
|
||||||
assert.Equal(t, uint(10), rep.MaxFails())
|
assert.Equal(t, uint(3), rep.MaxFails())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,8 @@ type WebhookJob struct {
|
||||||
|
|
||||||
// MaxFails returns that how many times this job can fail, get this value from ctx.
|
// MaxFails returns that how many times this job can fail, get this value from ctx.
|
||||||
func (wj *WebhookJob) MaxFails() (result uint) {
|
func (wj *WebhookJob) MaxFails() (result uint) {
|
||||||
// Default max fails count is 10, and its max retry interval is around 3h
|
// Default max fails count is 3
|
||||||
// Large enough to ensure most situations can notify successfully
|
result = 3
|
||||||
result = 10
|
|
||||||
if maxFails, exist := os.LookupEnv(maxFails); exist {
|
if maxFails, exist := os.LookupEnv(maxFails); exist {
|
||||||
mf, err := strconv.ParseUint(maxFails, 10, 32)
|
mf, err := strconv.ParseUint(maxFails, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
func TestMaxFails(t *testing.T) {
|
func TestMaxFails(t *testing.T) {
|
||||||
rep := &WebhookJob{}
|
rep := &WebhookJob{}
|
||||||
t.Run("default max fails", func(t *testing.T) {
|
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) {
|
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.Run("user defined wrong max fails", func(t *testing.T) {
|
||||||
t.Setenv(maxFails, "abc")
|
t.Setenv(maxFails, "abc")
|
||||||
assert.Equal(t, uint(10), rep.MaxFails())
|
assert.Equal(t, uint(3), rep.MaxFails())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user