@@ -300,13 +300,25 @@ type JobConfig struct {
300
300
// RateLimit configuration.
301
301
RateLimit RateLimitConfig `yaml:"rateLimit" mapstructure:"rateLimit"`
302
302
303
+ // GC configuration, used to clean up expired jobs. If the count of the jobs is huge,
304
+ // it may cause performance problems.
305
+ GC GCConfig `yaml:"gc" mapstructure:"gc"`
306
+
303
307
// Preheat configuration.
304
308
Preheat PreheatConfig `yaml:"preheat" mapstructure:"preheat"`
305
309
306
310
// Sync peers configuration.
307
311
SyncPeers SyncPeersConfig `yaml:"syncPeers" mapstructure:"syncPeers"`
308
312
}
309
313
314
+ type GCConfig struct {
315
+ // Interval is the interval for gc.
316
+ Interval time.Duration `yaml:"interval" mapstructure:"interval"`
317
+
318
+ // TTL is the ttl for job.
319
+ TTL time.Duration `yaml:"ttl" mapstructure:"ttl"`
320
+ }
321
+
310
322
type PreheatConfig struct {
311
323
// RegistryTimeout is the timeout for requesting registry to get token and manifest.
312
324
RegistryTimeout time.Duration `yaml:"registryTimeout" mapstructure:"registryTimeout"`
@@ -466,6 +478,10 @@ func New() *Config {
466
478
Capacity : DefaultJobRateLimitCapacity ,
467
479
Quantum : DefaultJobRateLimitQuantum ,
468
480
},
481
+ GC : GCConfig {
482
+ Interval : DefaultJobGCInterval ,
483
+ TTL : DefaultJobGCTTL ,
484
+ },
469
485
Preheat : PreheatConfig {
470
486
RegistryTimeout : DefaultJobPreheatRegistryTimeout ,
471
487
},
@@ -647,6 +663,14 @@ func (cfg *Config) Validate() error {
647
663
return errors .New ("rateLimit requires parameter quantum" )
648
664
}
649
665
666
+ if cfg .Job .GC .Interval == 0 {
667
+ return errors .New ("gc requires parameter interval" )
668
+ }
669
+
670
+ if cfg .Job .GC .TTL == 0 {
671
+ return errors .New ("gc requires parameter ttl" )
672
+ }
673
+
650
674
if cfg .Job .Preheat .TLS != nil {
651
675
if cfg .Job .Preheat .TLS .CACert == "" {
652
676
return errors .New ("preheat requires parameter caCert" )
0 commit comments