mirror of
https://github.com/goharbor/harbor
synced 2024-09-21 02:29:54 +00:00
fix: remove default execution sweeper count
1. Remove the default execution sweeper count for execution vendor. 2. Set the execution sweeper count for gc, preheat, replication, retention to 50. 3. Disable sweep for the executions of the scan job. Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
parent
506c2d809d
commit
712fe37ee0
|
@ -2,6 +2,7 @@ package gc
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
|
@ -9,6 +10,11 @@ import (
|
|||
"github.com/goharbor/harbor/src/pkg/task"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// keep only the latest created 50 gc execution records
|
||||
task.SetExecutionSweeperCount(GCVendorType, 50)
|
||||
}
|
||||
|
||||
var (
|
||||
// Ctl is a global garbage collection controller instance
|
||||
Ctl = NewController()
|
||||
|
|
|
@ -44,6 +44,11 @@ import (
|
|||
"github.com/goharbor/harbor/src/pkg/task"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// keep only the latest created 50 p2p preheat execution records
|
||||
task.SetExecutionSweeperCount(job.P2PPreheat, 50)
|
||||
}
|
||||
|
||||
const (
|
||||
defaultSeverityCode = 99
|
||||
extraAttrTotal = "totalCount"
|
||||
|
|
|
@ -29,6 +29,11 @@ import (
|
|||
"github.com/goharbor/harbor/src/replication/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// keep only the latest created 50 replication execution records
|
||||
task.SetExecutionSweeperCount(job.Replication, 50)
|
||||
}
|
||||
|
||||
// Controller defines the operations related with replication
|
||||
type Controller interface {
|
||||
// Start the replication according to the policy
|
||||
|
|
|
@ -17,6 +17,8 @@ package retention
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
|
@ -26,9 +28,13 @@ import (
|
|||
"github.com/goharbor/harbor/src/pkg/retention/policy"
|
||||
"github.com/goharbor/harbor/src/pkg/scheduler"
|
||||
"github.com/goharbor/harbor/src/pkg/task"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// keep only the latest created 50 retention execution records
|
||||
task.SetExecutionSweeperCount(job.Retention, 50)
|
||||
}
|
||||
|
||||
// go:generate mockery -name Controller -case snake
|
||||
|
||||
// Controller to handle the requests related with retention
|
||||
|
|
|
@ -31,9 +31,8 @@ import (
|
|||
|
||||
var (
|
||||
// ExecMgr is a global execution manager instance
|
||||
ExecMgr = NewExecutionManager()
|
||||
executionSweeperCount = map[string]uint8{}
|
||||
defaultExecutionSweeperCount uint8 = 50
|
||||
ExecMgr = NewExecutionManager()
|
||||
executionSweeperCount = map[string]uint8{}
|
||||
)
|
||||
|
||||
// ExecutionManager manages executions.
|
||||
|
@ -139,8 +138,10 @@ func (e *executionManager) Create(ctx context.Context, vendorType string, vendor
|
|||
func (e *executionManager) sweep(ctx context.Context, vendorType string, vendorID int64) error {
|
||||
count := executionSweeperCount[vendorType]
|
||||
if count == 0 {
|
||||
count = defaultExecutionSweeperCount
|
||||
log.Debugf("the execution sweeper count doesn't set for %s, skip sweep", vendorType)
|
||||
return nil
|
||||
}
|
||||
|
||||
for {
|
||||
// the function "List" of the execution manager returns the execution records
|
||||
// ordered by start time. After the sorting is supported in query, we should
|
||||
|
|
|
@ -58,6 +58,8 @@ func (e *executionManagerTestSuite) TestCount() {
|
|||
}
|
||||
|
||||
func (e *executionManagerTestSuite) TestCreate() {
|
||||
SetExecutionSweeperCount("vendor", 50)
|
||||
|
||||
e.execDAO.On("Create", mock.Anything, mock.Anything).Return(int64(1), nil)
|
||||
e.ormCreator.On("Create").Return(&orm.FakeOrmer{})
|
||||
e.execDAO.On("List", mock.Anything, mock.Anything).Return(nil, nil)
|
||||
|
|
Loading…
Reference in New Issue
Block a user