Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
Description
Override of user defined resources that have been evaluated will just change its parameters without re-evaluating its body. It also says nothing about that this happened. This is a problem in itself since it means that the resource will end up in the catalog with different parameters than those that were used when its body was evaluated. It is like having evaluated "add(2,2)=>4" and then changing it so it is reported as "add(3,2)=>4". This is total nonsense.
define foo($message) { notify {"$title n1": message => $message } } |
notify { 'n1': message => 'unchanged' } |
foo {'f1': message => 'unchanged' } |
define delayed { |
Notify <| title == 'n1' |> { message => 'changed' } |
Foo <| title == 'f1' |> { message => 'changed' } |
}
|
delayed {'d1': } |
Produces:
Notice: Compiled catalog for funnybones.com in environment production in 0.06 seconds
|
Notice: changed
|
Notice: /Stage[main]/Main/Notify[n1]/message: defined 'message' as 'changed'
|
Notice: unchanged
|
Notice: /Stage[main]/Main/Foo[f1]/Notify[f1 n1]/message: defined 'message' as 'unchanged'
|
In the example above it can be noted that the notify resource in the 'foo' body is unchanged since the parameters to Foo[f1] was changed after evaluation.
This means that override is sensitive to evaluation order. We cannot perform reevaluation of the resource as it ultimately leads to the ability to write infinite loops (the change causes it to do another override, it could then also be used to affect the logic that included it in the first place which in essence means user has access to the catalog and can mutate anything (although with a horrible blunt API).
It should probably be an error to override something that has already been evaluated as the result that is produced is nonsense. Such a change is however not backwards compatible since currently nothing much happens and the change would break manifests that do this.
The more drastic approach of removing overrides will not work as long as what it is used to solve is not supported in a better way (e.g. merging reources).