Skip to content

Always parse template wait intervals to avoid unnecessary rendering. #2014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions manager/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,36 @@ func (r *Runner) Start() {
log.Printf("[DEBUG] (runner) watching %d dependencies", r.watcher.Size())
}

// Enable quiescence for all templates if we have specified wait
// intervals. Those sould be parsed regardless of the allTemplatesRendered.
// In certain cases, due to dependencies, allTemplatesRendered is never
// reached, or reached much further down the runtime, leading to
// template rendering overflow, especially on templates receiving
// frequent updates.
NEXT_Q:
for _, t := range r.templates {
if _, ok := r.quiescenceMap[t.ID()]; ok {
continue NEXT_Q
}

c := r.templateConfigFor(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 r.allTemplatesRendered() {
log.Printf("[DEBUG] (runner) all templates rendered")

Expand All @@ -323,32 +353,6 @@ func (r *Runner) Start() {
r.readyCh <- struct{}{}
}

// 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
}

c := r.templateConfigFor(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.
if !r.config.Exec.Command.Empty() {
Expand Down
Loading