Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
PUP 7.0.0, PUP 6.12.0
-
None
-
-
Coremunity
-
Platform Core KANBAN
-
Needs Assessment
-
42173
-
1
-
Bug Fix
-
Puppet 6.12.0 introduced a regression that caused the result of a deferred function to be stored in the cached catalog. As a result, an agent running with a cached catalog, would not re-evaluate the deferred function. Now it does.
-
Needs Assessment
Description
The cached catalog contains the result of evaluating the deferred function, instead of the function. So if the agent applies a cached catalog, it will always apply the result of the deferred function when the cached catalog was saved instead of when the agent runs.
To reproduce, create:
cat /etc/puppetlabs/code/environments/production/manifests/site.pp
|
$epp_var = { |
'deferred_function' => Deferred('to_yaml', [{'test' => 'foo'}]) |
}
|
file { '/tmp/deferred_function.txt': |
content => Deferred('inline_epp', ['<%= $deferred_function -%>', $epp_var]), |
}
|
In 6.11.0, we correctly cache the deferred function:
$ cat ~/.puppetlabs/opt/puppet/cache/client_data/catalog/$(facter fqdn).json| jq .
|
...
|
{
|
"type": "File",
|
"title": "/tmp/deferred_function.txt",
|
"tags": [
|
"file",
|
"class"
|
],
|
"file": "/etc/puppetlabs/code/environments/production/manifests/site.pp",
|
"line": 4,
|
"exported": false,
|
"parameters": {
|
"content": {
|
"__ptype": "Deferred",
|
"name": "inline_epp",
|
"arguments": [
|
"<%= $deferred_function -%>",
|
{
|
"deferred_function": {
|
"__ptype": "Deferred",
|
"name": "to_yaml",
|
"arguments": [
|
{
|
"test": "foo"
|
}
|
]
|
}
|
}
|
]
|
}
|
}
|
and the file contains the result of evaluating the deferred function:
$ cat /tmp/deferred_function.txt
|
---
|
test: foo
|
In 6.12.0 the cached catalog is incorrect:
{
|
"type": "File",
|
"title": "/tmp/deferred_function.txt",
|
"tags": [
|
"file",
|
"class"
|
],
|
"file": "/etc/puppetlabs/code/environments/production/manifests/site.pp",
|
"line": 4,
|
"exported": false,
|
"parameters": {
|
"content": "---\ntest: foo\n"
|
}
|
}
|
The bug was introduced in a17761d60b2e5d42cc01a36e1d6ba3d790c9dcf8, as there was a semantic conflict due to the environment convergence changes in 5.5.x and the deferred functionality in 6.x.