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

(GH-97) Memoize class variables in initialize #98

Merged
merged 1 commit into from
Feb 3, 2021
Merged

(GH-97) Memoize class variables in initialize #98

merged 1 commit into from
Feb 3, 2021

Conversation

michaeltlombardi
Copy link
Contributor

Prior to this PR calling initialize for the dsc base provider would always set the class variables for cached_canonicalized_resource, cached_query_results, and logon_failures to empty arrays; when running with 2 or more resources of a different type, this would cause the provider to reset these values to the empty arrays, thus wiping out these caches, especially the cache for canonicalized resources, which is filled before the rest of the Puppet run.

This commit updates the initialize method to instead memoize those caches, only setting them to empty arrays if they do not already exist. This way, canonicalized resources from multiple types are not mysteriously removed from the cache.

Prior to this commit calling initialize for the dsc base provider
would always set the class variables for cached_canonicalized_resource,
cached_query_results, and logon_failures to empty arrays; when
running with 2 or more resources of a different type, this would
cause the provider to reset these values to the empty arrays, thus
wiping out these caches, especially the cache for canonicalized
resources, which is filled *before* the rest of the Puppet run.

This commit updates the initialize method to instead memoize those
caches, only setting them to empty arrays if they do not already
exist. This way, canonicalized resources from multiple types are
not mysteriously removed from the cache.
@sanfrancrisko sanfrancrisko merged commit 164c995 into puppetlabs:main Feb 3, 2021
@michaeltlombardi michaeltlombardi deleted the gh-97/main/memoize-class-variables branch February 3, 2021 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors when mixing dsc resources
3 participants