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-125) Fix dsc provider canonicalization for absent resources #129

Merged
merged 5 commits into from
May 14, 2021
Merged

(GH-125) Fix dsc provider canonicalization for absent resources #129

merged 5 commits into from
May 14, 2021

Conversation

michaeltlombardi
Copy link
Contributor

@michaeltlombardi michaeltlombardi commented May 11, 2021

Prior to this PR the canonicalize method in the DSC Base Provider did some unneccessary work:

  • it always called invoke_get_method if a resource was not already in the canonicalized cache
  • it erroneously canonicalized a resource which should exist to values which were returned as nil from invoke_get_method because DSC returns the ensure value as absent and nil for other properties

This commit adds logic shortcuts to obviate unneccessary canonicalization of the resource when the should value for dsc_ensure is absent (because a resource being deleted does not care about casing) as well as when the should value for dsc_ensure is present but the resource itself does not actually exist on the system (a resource which is being created should treat it's own definition as canonical).

Prior to this commit the canonicalize method in the DSC Base provider
did some unneccessary work:

- it _always_ called invoke_get_method if a resource was not already
  in the canonicalized cache
- it erroneously canonicalized a resource which *should* exist to
  values which were returned as nil from invoke_get_method because
  DSC returns the ensure value as absent and nil for other properties

This commit adds logic shortcuts to obviate unneccessary canonicalization
of the resource when the should value for dsc_ensure is absent (because
a resource being deleted does not care about casing) as well as when the
should value for dsc_ensure is present but the resource itself does not
actually exist on the system (canonicalizing to a nil state is a bug).
@michaeltlombardi
Copy link
Contributor Author

While this is currently functional, there is some refactoring necessary to make the tests more maintainable and readable; I ran out of time today but will get that in tomorrow.

@michaeltlombardi michaeltlombardi marked this pull request as ready for review May 12, 2021 17:53
@michaeltlombardi michaeltlombardi requested a review from a team as a code owner May 12, 2021 17:53
@DavidS DavidS merged commit 12f4293 into puppetlabs:main May 14, 2021
@michaeltlombardi michaeltlombardi deleted the gh-125/main/canonicalize-absent branch May 14, 2021 11:32
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.

DSC Base Provider: Canonicalize absent resources properly
2 participants