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

Implement Validation Mode Flag for Puppet Resources #145

Closed
12 tasks done
michaeltlombardi opened this issue Apr 20, 2021 · 1 comment
Closed
12 tasks done

Implement Validation Mode Flag for Puppet Resources #145

michaeltlombardi opened this issue Apr 20, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@michaeltlombardi
Copy link

michaeltlombardi commented Apr 20, 2021

Use Case

In the course of early user feedback for the Puppetized DSC modules, we have discovered that numerous DSC Resources are not able to have their state properly validated using the default property insync logic in Puppet. The sorts of problems encountered are as complicated as the issues in ActiveDirectoryDsc and NetworkingDsc or as straightforward as a Resource not returning a key property in Get (see these two PRs: 1, 2).

When property-by-property state comparisons are not possible, one of several problems from this non-exhaustive list can show up:

  1. Flapping resources, applying on every run
  2. Resources applying state when they shouldn't
  3. Resources not applying state when they should
  4. Resources erroring on type mismatches of desired state and actual

Describe the Solution You Would Like

When puppetlabs/puppet-resource_api#285 is merged and available in Puppet 6&7 it will be possible to implement a custom insync? method on the DSC base provider. This would enable the use of DSC's own state comparison checking to be leveraged in place of Puppet's. However, it would do so at the cost of property-by-property reporting; DSC's Test method invocation returns only true or false and does not indicate which properties, if any, are out of desired state.

Enabling this override should be on a resource-by-resource case in the manifest, with the default behavior being the existing property-by-property reporting. If an override is specified to instead use the less granular test method for comparing desired state.

Additional Context

The following issues would all benefit from using a resource validation mode instead of property-by-property:

Acceptance Criteria

  • Builder
    • Add custom_insync feature to generated types
    • Add new validation_mode attribute to generated types which takes the enums property and resource, defaulting to property
    • Add documentation for validation_mode and especially guidance on when to use it
    • Add acceptance tests for a resource which fails with validation_mode set to property but succeeds with validation_mode set to resource
  • Base Provider
    • Add a new class variable to cache the test results, similar to cached_query_results
    • Add a new invoke_test_method which passes a should hash to Invoke-DscResource and caches the result to cached_query_results
    • Add a new insync? method which takes context, name, attribute_name, is_hash, and should_hash parameters:
      • If validation_mode is set to resource:
        • call invoke_test_method unless the resource insync state is already cached in cached_test_results
        • Return true if in desired state and false if not
      • If validation_mode is set to property:
        • Do nothing, allow the default insync checks to occur
    • Unit tests for invoke_test_method
    • Unit tests for insync?
@michaeltlombardi michaeltlombardi added the enhancement New feature or request label Apr 20, 2021
@michaeltlombardi michaeltlombardi added this to the 002: End to End Testing milestone Apr 20, 2021
@michaeltlombardi michaeltlombardi self-assigned this Apr 20, 2021
@michaeltlombardi
Copy link
Author

Blocked on the next releases of Puppet (6.23.0 and 7.?.? and the PDK which incorporates them).

@michaeltlombardi michaeltlombardi removed this from the 002: End to End Testing & 1.0.0 Release milestone Jun 14, 2021
david22swan added a commit that referenced this issue Jun 28, 2021
…ion_mode

(GH-145) Add validation mode flag to puppetized DSC Resources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant