Skip to content

Commit

Permalink
add multiple deletion of GC
Browse files Browse the repository at this point in the history
User can specify the workers when to issue an GC execution, the maxium count of workers is 5.

Signed-off-by: wang yan <wangyan@vmware.com>
  • Loading branch information
wy65701436 authored and System Administrator committed Jun 27, 2023
1 parent 46f1fb0 commit 3b5b6ad
Show file tree
Hide file tree
Showing 14 changed files with 494 additions and 136 deletions.
2 changes: 2 additions & 0 deletions src/controller/gc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (c *controller) Start(ctx context.Context, policy Policy, trigger string) (
para := make(map[string]interface{})
para["delete_untagged"] = policy.DeleteUntagged
para["dry_run"] = policy.DryRun
para["workers"] = policy.Workers
para["redis_url_reg"] = policy.ExtraAttrs["redis_url_reg"]
para["time_window"] = policy.ExtraAttrs["time_window"]

Expand Down Expand Up @@ -233,6 +234,7 @@ func convertTask(task *task.Task) *Task {
RunCount: task.RunCount,
DeleteUntagged: task.GetBoolFromExtraAttrs("delete_untagged"),
DryRun: task.GetBoolFromExtraAttrs("dry_run"),
Workers: int(task.GetNumFromExtraAttrs("workers")),
JobID: task.JobID,
CreationTime: task.CreationTime,
StartTime: task.StartTime,
Expand Down
2 changes: 2 additions & 0 deletions src/controller/gc/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Policy struct {
Trigger *Trigger `json:"trigger"`
DeleteUntagged bool `json:"deleteuntagged"`
DryRun bool `json:"dryrun"`
Workers int `json:"workers"`
ExtraAttrs map[string]interface{} `json:"extra_attrs"`
}

Expand Down Expand Up @@ -60,6 +61,7 @@ type Task struct {
RunCount int32
DeleteUntagged bool
DryRun bool
Workers int
JobID string
CreationTime time.Time
StartTime time.Time
Expand Down
2 changes: 1 addition & 1 deletion src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ require (
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
github.com/pkg/errors v0.9.1

github.com/prometheus/client_golang v1.14.0
github.com/robfig/cron/v3 v3.0.0
github.com/spf13/viper v1.8.1
Expand Down Expand Up @@ -163,6 +162,7 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.0 // indirect
golang.org/x/sync v0.1.0
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
google.golang.org/api v0.110.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180224232135-f6cff0780e54/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
Loading

0 comments on commit 3b5b6ad

Please sign in to comment.