Skip to content
Snippets Groups Projects
Commit 590307ba authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

Merge branch 'move-ticker-creation' into 'develop'

move ticker creation to commit

See merge request !188
parents 7edb4dc1 874d48f8
No related branches found
No related tags found
9 merge requests!246Develop,!245Develop into Master,!244Master into develop2 into master,!219Draft: Testing,!214Test pipelines,!195DO NOT MERGE 2,!194DO NOT MERGE! just for testing,!188move ticker creation to commit,!138Develop
Pipeline #80479 passed with warnings
......@@ -117,26 +117,27 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, <
stateOut := make(chan ppb.Change_State)
stateRequest := make(chan bool)
errChan := make(chan error)
ticker := time.NewTicker(timeout)
// create ticker and make it wait for 1 week
// workaround for delayed ticker start and ugly housekeeping
ticker := time.NewTicker(time.Hour * 7 * 24)
go func() {
state := ppb.Change_PENDING
for {
select {
case <-ticker.C:
// only roll back committed changes
if state == ppb.Change_COMMITTED {
err := ch.callback(ch.intendedState, ch.previousState)
if err != nil {
state = ppb.Change_INCONSISTENT
errChan <- err
}
errChan <- fmt.Errorf("change %v timed out", ch.cuid)
break
err := ch.callback(ch.intendedState, ch.previousState)
if err != nil {
state = ppb.Change_INCONSISTENT
errChan <- err
}
errChan <- fmt.Errorf("change %v timed out", ch.cuid)
break
case s := <-stateIn:
switch s {
case ppb.Change_COMMITTED:
// reset ticker to enable activate the change timeout
ticker.Reset(timeout)
err := ch.callback(ch.previousState, ch.intendedState)
if err != nil {
state = ppb.Change_INCONSISTENT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment