mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 21:54:13 +01:00
fix: update the jobservice hook retry concurrency (#17024)
Change the jobservice hook max retry concurrency from 512 to same with the js worker numbers. Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
parent
6c515b04d4
commit
c7e153654a
@ -33,8 +33,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
// Backoff duration of direct retrying.
|
// Backoff duration of direct retrying.
|
||||||
errRetryBackoff = 5 * time.Minute
|
errRetryBackoff = 5 * time.Minute
|
||||||
// Max concurrency of retrying goroutines.
|
|
||||||
maxConcurrency = 512
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Agent is designed to handle the hook events with reasonable numbers of concurrent threads.
|
// Agent is designed to handle the hook events with reasonable numbers of concurrent threads.
|
||||||
@ -75,13 +73,13 @@ type basicAgent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewAgent is constructor of basic agent
|
// NewAgent is constructor of basic agent
|
||||||
func NewAgent(ctx *env.Context, ns string, redisPool *redis.Pool) Agent {
|
func NewAgent(ctx *env.Context, ns string, redisPool *redis.Pool, retryConcurrency uint) Agent {
|
||||||
return &basicAgent{
|
return &basicAgent{
|
||||||
context: ctx.SystemContext,
|
context: ctx.SystemContext,
|
||||||
namespace: ns,
|
namespace: ns,
|
||||||
client: NewClient(ctx.SystemContext),
|
client: NewClient(ctx.SystemContext),
|
||||||
redisPool: redisPool,
|
redisPool: redisPool,
|
||||||
tokens: make(chan struct{}, maxConcurrency),
|
tokens: make(chan struct{}, retryConcurrency),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ func NewClient(ctx context.Context) Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 15 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,8 @@ func (bs *Bootstrap) LoadAndRun(ctx context.Context, cancel context.CancelFunc)
|
|||||||
// Create stats manager
|
// Create stats manager
|
||||||
manager = mgt.NewManager(ctx, namespace, redisPool)
|
manager = mgt.NewManager(ctx, namespace, redisPool)
|
||||||
// Create hook agent, it's a singleton object
|
// Create hook agent, it's a singleton object
|
||||||
hookAgent := hook.NewAgent(rootContext, namespace, redisPool)
|
// the retryConcurrency keep same with worker num
|
||||||
|
hookAgent := hook.NewAgent(rootContext, namespace, redisPool, workerNum)
|
||||||
hookCallback := func(URL string, change *job.StatusChange) error {
|
hookCallback := func(URL string, change *job.StatusChange) error {
|
||||||
msg := fmt.Sprintf(
|
msg := fmt.Sprintf(
|
||||||
"status change: job=%s, status=%s, revision=%d",
|
"status change: job=%s, status=%s, revision=%d",
|
||||||
|
Loading…
Reference in New Issue
Block a user