func (c *Cron) SyncConfig(cfg *config.Config) error {
	c.lock.Lock()
	defer c.lock.Unlock()

	for _, p := range cfg.Periodics {
		if err := c.addPeriodic(p); err != nil {
			return err
		}
	}

	periodicNames := sets.NewString()
	for _, p := range cfg.AllPeriodics() {
		periodicNames.Insert(p.Name)
	}

	existing := sets.NewString()
	for k := range c.jobs {
		existing.Insert(k)
	}

	var removalErrors []error
	for _, job := range existing.Difference(periodicNames).List() {
		if err := c.removeJob(job); err != nil {
			removalErrors = append(removalErrors, err)
		}
	}

	return errorutil.NewAggregate(removalErrors...)
}
func (c *Cron) SyncConfig(cfg *config.Config) error {
	c.lock.Lock()
	defer c.lock.Unlock()

	for _, p := range cfg.Periodics {
		if err := c.addPeriodic(p); err != nil {
			return err
		}
	}

	periodicNames := sets.NewString()
	for _, p := range cfg.AllPeriodics() {
		periodicNames.Insert(p.Name)
	}

	existing := sets.NewString()
	for k := range c.jobs {
		existing.Insert(k)
	}

	var removalErrors []error
	for _, job := range existing.Difference(periodicNames).List() {
		if err := c.removeJob(job); err != nil {
			removalErrors = append(removalErrors, err)
		}
	}

	return errorutil.NewAggregate(removalErrors...)
}
// SyncConfig syncs current cronAgent with current prow config
// which add/delete jobs accordingly.