Skip to content
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

fix: handle template re-renders on client restart #24399

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

mismithhisler
Copy link
Member

When multiple templates with api functions are included in a task, it's possible for consul-template to re-render templates as it creates watchers, overwriting render event data. This change uses event fields that do not get overwritten, and only executes the change mode for templates that were actually written to disk.

Fixes: #24140

When multiple templates with api functions are included in a task, it's
possible for consul-template to re-render templates as it creates
watchers, overwriting render event data. This change uses event fields
that do not get overwritten, and only executes the change mode for
templates that were actually written to disk.
@mismithhisler mismithhisler self-assigned this Nov 7, 2024
@mismithhisler mismithhisler added backport/1.7.x backport to 1.7.x release line backport/1.8.x backport to 1.8.x release line backport/1.9.x backport to 1.9.x release line backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent and removed backport/1.7.x backport to 1.7.x release line backport/1.8.x backport to 1.8.x release line labels Nov 7, 2024
Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work hunting this down!

client/allocrunner/taskrunner/template/template.go Outdated Show resolved Hide resolved
client/allocrunner/taskrunner/template/template_test.go Outdated Show resolved Hide resolved
Comment on lines +812 to +813
// We cannot control the order in which these templates are rendered, so this test will
// exhibit flakiness if this edge case is not properly handled.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me want a test rig where we can mock CT and step thru its operations deterministically... but that's a ton of work, probably better fixed by pulling the runner in-tree, and way out of scope for this PR. 😁

Co-authored-by: Tim Gross <tgross@hashicorp.com>
@mismithhisler mismithhisler merged commit 0714353 into main Nov 8, 2024
26 checks passed
@mismithhisler mismithhisler deleted the b-handle-template-rerender-on-restart branch November 8, 2024 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.9.x backport to 1.9.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template change_mode intermittently ignored after client restart
2 participants