mirror of
https://github.com/fluxcd/flagger.git
synced 2026-02-22 22:03:59 +00:00
- Currently whenever the Canary analysis interval changes, flagger does not reflect this into canary's job. - This change will make sure the canary analysis interval got updated whenever the Canary object's interval changes
41 lines
887 B
Go
41 lines
887 B
Go
package controller
|
|
|
|
import "time"
|
|
|
|
// CanaryJob holds the reference to a canary deployment schedule
|
|
type CanaryJob struct {
|
|
Name string
|
|
Namespace string
|
|
SkipTests bool
|
|
function func(name string, namespace string, skipTests bool)
|
|
done chan bool
|
|
ticker *time.Ticker
|
|
analysisInterval time.Duration
|
|
}
|
|
|
|
// Start runs the canary analysis on a schedule
|
|
func (j CanaryJob) Start() {
|
|
go func() {
|
|
// run the infra bootstrap on job creation
|
|
j.function(j.Name, j.Namespace, j.SkipTests)
|
|
for {
|
|
select {
|
|
case <-j.ticker.C:
|
|
j.function(j.Name, j.Namespace, j.SkipTests)
|
|
case <-j.done:
|
|
return
|
|
}
|
|
}
|
|
}()
|
|
}
|
|
|
|
// Stop closes the job channel and stops the ticker
|
|
func (j CanaryJob) Stop() {
|
|
close(j.done)
|
|
j.ticker.Stop()
|
|
}
|
|
|
|
func (j CanaryJob) GetCanaryAnalysisInterval() time.Duration {
|
|
return j.analysisInterval
|
|
}
|