refactor: remove legacy job gc config (#3995)
Signed-off-by: chlins <chlins.zhang@gmail.com>
This commit is contained in:
parent
36c110b358
commit
50083ff6b4
|
|
@ -304,10 +304,6 @@ type GRPCTLSServerConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobConfig struct {
|
type JobConfig struct {
|
||||||
// GC configuration, used to clean up expired jobs. If the count of the jobs is huge,
|
|
||||||
// it may cause performance problems.
|
|
||||||
GC GCConfig `yaml:"gc" mapstructure:"gc"`
|
|
||||||
|
|
||||||
// Preheat configuration.
|
// Preheat configuration.
|
||||||
Preheat PreheatConfig `yaml:"preheat" mapstructure:"preheat"`
|
Preheat PreheatConfig `yaml:"preheat" mapstructure:"preheat"`
|
||||||
|
|
||||||
|
|
@ -315,17 +311,6 @@ type JobConfig struct {
|
||||||
SyncPeers SyncPeersConfig `yaml:"syncPeers" mapstructure:"syncPeers"`
|
SyncPeers SyncPeersConfig `yaml:"syncPeers" mapstructure:"syncPeers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GCConfig struct {
|
|
||||||
// Interval is the interval for gc.
|
|
||||||
Interval time.Duration `yaml:"interval" mapstructure:"interval"`
|
|
||||||
|
|
||||||
// TTL is the ttl for job.
|
|
||||||
TTL time.Duration `yaml:"ttl" mapstructure:"ttl"`
|
|
||||||
|
|
||||||
// BatchSize is the batch size when operating gorm database.
|
|
||||||
BatchSize int `yaml:"batchSize" mapstructure:"batchSize"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PreheatConfig struct {
|
type PreheatConfig struct {
|
||||||
// RegistryTimeout is the timeout for requesting registry to get token and manifest.
|
// RegistryTimeout is the timeout for requesting registry to get token and manifest.
|
||||||
RegistryTimeout time.Duration `yaml:"registryTimeout" mapstructure:"registryTimeout"`
|
RegistryTimeout time.Duration `yaml:"registryTimeout" mapstructure:"registryTimeout"`
|
||||||
|
|
@ -444,11 +429,6 @@ func New() *Config {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Job: JobConfig{
|
Job: JobConfig{
|
||||||
GC: GCConfig{
|
|
||||||
Interval: DefaultJobGCInterval,
|
|
||||||
TTL: DefaultJobGCTTL,
|
|
||||||
BatchSize: DefaultJobGCBatchSize,
|
|
||||||
},
|
|
||||||
Preheat: PreheatConfig{
|
Preheat: PreheatConfig{
|
||||||
RegistryTimeout: DefaultJobPreheatRegistryTimeout,
|
RegistryTimeout: DefaultJobPreheatRegistryTimeout,
|
||||||
TLS: PreheatTLSClientConfig{},
|
TLS: PreheatTLSClientConfig{},
|
||||||
|
|
@ -625,18 +605,6 @@ func (cfg *Config) Validate() error {
|
||||||
return errors.New("local requires parameter ttl")
|
return errors.New("local requires parameter ttl")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.Job.GC.Interval == 0 {
|
|
||||||
return errors.New("gc requires parameter interval")
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Job.GC.TTL == 0 {
|
|
||||||
return errors.New("gc requires parameter ttl")
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Job.GC.BatchSize == 0 {
|
|
||||||
return errors.New("gc requires parameter batchSize")
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Job.Preheat.RegistryTimeout == 0 {
|
if cfg.Job.Preheat.RegistryTimeout == 0 {
|
||||||
return errors.New("preheat requires parameter registryTimeout")
|
return errors.New("preheat requires parameter registryTimeout")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,6 @@ func TestConfig_Load(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Job: JobConfig{
|
Job: JobConfig{
|
||||||
GC: GCConfig{
|
|
||||||
Interval: 1 * time.Second,
|
|
||||||
TTL: 1 * time.Second,
|
|
||||||
BatchSize: 100,
|
|
||||||
},
|
|
||||||
Preheat: PreheatConfig{
|
Preheat: PreheatConfig{
|
||||||
RegistryTimeout: DefaultJobPreheatRegistryTimeout,
|
RegistryTimeout: DefaultJobPreheatRegistryTimeout,
|
||||||
TLS: PreheatTLSClientConfig{
|
TLS: PreheatTLSClientConfig{
|
||||||
|
|
@ -736,51 +731,6 @@ func TestConfig_Validate(t *testing.T) {
|
||||||
assert.EqualError(err, "local requires parameter ttl")
|
assert.EqualError(err, "local requires parameter ttl")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "gc requires parameter interval",
|
|
||||||
config: New(),
|
|
||||||
mock: func(cfg *Config) {
|
|
||||||
cfg.Auth.JWT = mockJWTConfig
|
|
||||||
cfg.Database.Type = DatabaseTypeMysql
|
|
||||||
cfg.Database.Mysql = mockMysqlConfig
|
|
||||||
cfg.Database.Redis = mockRedisConfig
|
|
||||||
cfg.Job.GC.Interval = 0
|
|
||||||
},
|
|
||||||
expect: func(t *testing.T, err error) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
assert.EqualError(err, "gc requires parameter interval")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "gc requires parameter ttl",
|
|
||||||
config: New(),
|
|
||||||
mock: func(cfg *Config) {
|
|
||||||
cfg.Auth.JWT = mockJWTConfig
|
|
||||||
cfg.Database.Type = DatabaseTypeMysql
|
|
||||||
cfg.Database.Mysql = mockMysqlConfig
|
|
||||||
cfg.Database.Redis = mockRedisConfig
|
|
||||||
cfg.Job.GC.TTL = 0
|
|
||||||
},
|
|
||||||
expect: func(t *testing.T, err error) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
assert.EqualError(err, "gc requires parameter ttl")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "gc requires parameter batchSize",
|
|
||||||
config: New(),
|
|
||||||
mock: func(cfg *Config) {
|
|
||||||
cfg.Auth.JWT = mockJWTConfig
|
|
||||||
cfg.Database.Type = DatabaseTypeMysql
|
|
||||||
cfg.Database.Mysql = mockMysqlConfig
|
|
||||||
cfg.Database.Redis = mockRedisConfig
|
|
||||||
cfg.Job.GC.BatchSize = 0
|
|
||||||
},
|
|
||||||
expect: func(t *testing.T, err error) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
assert.EqualError(err, "gc requires parameter batchSize")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "preheat requires parameter registryTimeout",
|
name: "preheat requires parameter registryTimeout",
|
||||||
config: New(),
|
config: New(),
|
||||||
|
|
|
||||||
|
|
@ -87,15 +87,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// DefaultJobGCInterval is the default interval for gc job.
|
|
||||||
DefaultJobGCInterval = 3 * time.Hour
|
|
||||||
|
|
||||||
// DefaultJobGCTTL is the default ttl for job.
|
|
||||||
DefaultJobGCTTL = 6 * time.Hour
|
|
||||||
|
|
||||||
// DefaultJobGCBatchSize is the default batch size for operating on the database in gc job.
|
|
||||||
DefaultJobGCBatchSize = 5000
|
|
||||||
|
|
||||||
// DefaultJobPreheatRegistryTimeout is the default timeout for requesting registry to get token and manifest.
|
// DefaultJobPreheatRegistryTimeout is the default timeout for requesting registry to get token and manifest.
|
||||||
DefaultJobPreheatRegistryTimeout = 1 * time.Minute
|
DefaultJobPreheatRegistryTimeout = 1 * time.Minute
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue