Skip to content

Commit

Permalink
init quiescence after all templates are rendered
Browse files Browse the repository at this point in the history
Hold off on initializing wait/quiescence until all templates have been
rendered once. This fixes an issue with -exec firing before the template
has been rendered when wait/quiescence is set, and it would also make
sure templates are rendered for once (if that wasn't already fixed
another way).

Fixes #1229
  • Loading branch information
eikenb committed Jul 29, 2019
1 parent 87b0d97 commit 5c5810e
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions manager/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,31 +221,6 @@ func (r *Runner) Start() {
}

for {
// Enable quiescence for all templates if we have specified wait
// intervals.
NEXT_Q:
for _, t := range r.templates {
if _, ok := r.quiescenceMap[t.ID()]; ok {
continue NEXT_Q
}

for _, c := range r.templateConfigsFor(t) {
if *c.Wait.Enabled {
log.Printf("[DEBUG] (runner) enabling template-specific quiescence for %q", t.ID())
r.quiescenceMap[t.ID()] = newQuiescence(
r.quiescenceCh, *c.Wait.Min, *c.Wait.Max, t)
continue NEXT_Q
}
}

if *r.config.Wait.Enabled {
log.Printf("[DEBUG] (runner) enabling global quiescence for %q", t.ID())
r.quiescenceMap[t.ID()] = newQuiescence(
r.quiescenceCh, *r.config.Wait.Min, *r.config.Wait.Max, t)
continue NEXT_Q
}
}

// Warn the user if they are watching too many dependencies.
if r.watcher.Size() > saneViewLimit {
log.Printf("[WARN] (runner) watching %d dependencies - watching this "+
Expand All @@ -256,6 +231,32 @@ func (r *Runner) Start() {

if r.allTemplatesRendered() {
log.Printf("[DEBUG] (runner) all templates rendered")
// Enable quiescence for all templates if we have specified wait
// intervals.
NEXT_Q:
for _, t := range r.templates {
if _, ok := r.quiescenceMap[t.ID()]; ok {
continue NEXT_Q
}

for _, c := range r.templateConfigsFor(t) {
if *c.Wait.Enabled {
log.Printf("[DEBUG] (runner) enabling template-specific "+
"quiescence for %q", t.ID())
r.quiescenceMap[t.ID()] = newQuiescence(
r.quiescenceCh, *c.Wait.Min, *c.Wait.Max, t)
continue NEXT_Q
}
}

if *r.config.Wait.Enabled {
log.Printf("[DEBUG] (runner) enabling global quiescence for %q",
t.ID())
r.quiescenceMap[t.ID()] = newQuiescence(
r.quiescenceCh, *r.config.Wait.Min, *r.config.Wait.Max, t)
continue NEXT_Q
}
}

// If an exec command was given and a command is not currently running,
// spawn the child process for supervision.
Expand Down

0 comments on commit 5c5810e

Please sign in to comment.