From 395ae77d64912864f572581b67eed2884d0c463e Mon Sep 17 00:00:00 2001 From: Chlins Zhang Date: Wed, 22 Mar 2023 17:36:50 +0800 Subject: [PATCH] fix: change the default max retry count for webhook job to 3 (#18392) Signed-off-by: chlins --- make/harbor.yml.tmpl | 2 +- .../photon/prepare/migrations/version_2_8_0/harbor.yml.jinja | 2 +- src/jobservice/job/impl/notification/slack_job.go | 5 ++--- src/jobservice/job/impl/notification/slack_job_test.go | 4 ++-- src/jobservice/job/impl/notification/webhook_job.go | 5 ++--- src/jobservice/job/impl/notification/webhook_job_test.go | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/make/harbor.yml.tmpl b/make/harbor.yml.tmpl index 88ba85daa..c9c9b990a 100644 --- a/make/harbor.yml.tmpl +++ b/make/harbor.yml.tmpl @@ -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 diff --git a/make/photon/prepare/migrations/version_2_8_0/harbor.yml.jinja b/make/photon/prepare/migrations/version_2_8_0/harbor.yml.jinja index 34c8d5ae0..d87218dfc 100644 --- a/make/photon/prepare/migrations/version_2_8_0/harbor.yml.jinja +++ b/make/photon/prepare/migrations/version_2_8_0/harbor.yml.jinja @@ -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 %} diff --git a/src/jobservice/job/impl/notification/slack_job.go b/src/jobservice/job/impl/notification/slack_job.go index c7db3b900..239b44b9b 100644 --- a/src/jobservice/job/impl/notification/slack_job.go +++ b/src/jobservice/job/impl/notification/slack_job.go @@ -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 { diff --git a/src/jobservice/job/impl/notification/slack_job_test.go b/src/jobservice/job/impl/notification/slack_job_test.go index 3d753ec8a..883a2b064 100644 --- a/src/jobservice/job/impl/notification/slack_job_test.go +++ b/src/jobservice/job/impl/notification/slack_job_test.go @@ -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()) }) } diff --git a/src/jobservice/job/impl/notification/webhook_job.go b/src/jobservice/job/impl/notification/webhook_job.go index 64531c1a9..fcefeff04 100644 --- a/src/jobservice/job/impl/notification/webhook_job.go +++ b/src/jobservice/job/impl/notification/webhook_job.go @@ -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 { diff --git a/src/jobservice/job/impl/notification/webhook_job_test.go b/src/jobservice/job/impl/notification/webhook_job_test.go index 0c1c8eaa3..27296124c 100644 --- a/src/jobservice/job/impl/notification/webhook_job_test.go +++ b/src/jobservice/job/impl/notification/webhook_job_test.go @@ -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()) }) }