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

(MODULES-6860) Add dsc_lite feature for confines #41

Conversation

Iristyle
Copy link
Contributor

@Iristyle Iristyle commented Mar 16, 2018

Similar to puppetlabs-toy-chest/puppetlabs-dsc#350 this is a quick fix that might require some further thought given there are currently two version checks against PowerShell performed in two different ways at different points in the lifecycle.

This builds on #40, but if this is merged first, #40 can be closed.

  • Previously when a version of PowerShell older than 5.0.10586.117
    was installed, Puppet would return an error message like:

    Error: Could not find a suitable provider for dsc

    Unfortunately this message did not yield any useful information,
    even with --debug and --verbose turned on, because of the way the
    existing confine check was performed with a confine :true

    To produce a more useful message that is meaningful to users,
    introduce a new feature that performs the same check as the
    confine, but that also will issue an error message (only once)
    that indicates the installed version / required version constraints
    for the module, changing the output to:.

    Error: The dsc_lite module requires PowerShell version 5.0.10586.117 - current version 5.0.10514.6

    The cmdlet Invoke-DscResource was introduced in v5.0, and is necessary for the
    dsc_lite module to function. Further bug fixes, first made available in version
    5.0.10586.117 are also necessary for this module to function.

    To enable this module, please install the latest version of WMF 5+ from Microsoft.\n (file & line not available)

  • Note that DSC_LITE_MODULE_POWERSHELL_UPGRADE_MSG is never actually
    shown when the PowerShell version is < 5.0.10586.117 because the
    check occurs too late in the lifecycle of loading providers. The
    confine code has already evaluated, preventing the other messsages
    from being shown. This will be removed in subsequent commit.

  • The new feature can be used in place of the previous
    CompatiblePowerShellVersion.compatible_version? check

  • The message for DSC_LITE_MODULE_POWERSHELL_UPGRADE_MSG that was
    intended to be shown inside the provider wasn't, since the
    checks made in the type for PowerShell compatibility occurred
    earlier in the Puppet run lifecycle.

  • This prevents duplication of version checks in multiple locations

  • Remove compatible_powershell_version_spec.rb given the code
    has been removed.

@Iristyle Iristyle changed the title Modules 6860 add dsc lite feature improve confine messages (MODULES-6860) Add dsc_lite feature for confines Mar 16, 2018
@Iristyle Iristyle force-pushed the MODULES-6860-add-dsc_lite-feature-improve-confine-messages branch 2 times, most recently from 969ad8d to 995e089 Compare March 16, 2018 00:28
Copy link
Contributor

@RandomNoun7 RandomNoun7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change manually verified. Running through adhoc.

@RandomNoun7
Copy link
Contributor

Previous error messge

Error: Could not find a suitable provider for dsc

New error message

Error: The dsc_lite module requires PowerShell version 5.0.10586.117 - current version 2.0\n   (file & line not available)
Error: Could not find a suitable provider for dsc

RandomNoun7
RandomNoun7 previously approved these changes May 9, 2018
@Iristyle Iristyle force-pushed the MODULES-6860-add-dsc_lite-feature-improve-confine-messages branch from 995e089 to 4f79735 Compare May 10, 2018 15:32
if (installed_version >= required_version)
Puppet.features.add(:dsc_lite)
else
Puppet.warn_once(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 - Previously when a version of PowerShell older than 5.0.10586.117
   was installed, Puppet would return an error message like:

   Error: Could not find a suitable provider for dsc

   Unfortunately this message did not yield any useful information,
   even with --debug and --verbose turned on, because of the way the
   existing confine check was performed with a confine :true

   To produce a more useful message that is meaningful to users,
   introduce a new feature that performs the same check as the
   confine, but that also will issue an error message (only once)
   that indicates the installed version / required version constraints
   for the module, changing the output to:.

   Error: The dsc_lite module requires PowerShell version 5.0.10586.117 - current version 5.0.10514.6

   The cmdlet Invoke-DscResource was introduced in v5.0, and is necessary for the
   dsc_lite module to function. Further bug fixes, first made available in version
   5.0.10586.117 are also necessary for this module to function.

   To enable this module, please install the latest version of WMF 5+ from Microsoft.\n   (file & line not available)

 - Note that DSC_LITE_MODULE_POWERSHELL_UPGRADE_MSG is never actually
   shown when the PowerShell version is < 5.0.10586.117 because the
   check occurs too late in the lifecycle of loading providers. The
   confine code has already evaluated, preventing the other messsages
   from being shown. This will be removed in subsequent commit.
@Iristyle Iristyle force-pushed the MODULES-6860-add-dsc_lite-feature-improve-confine-messages branch 4 times, most recently from de5b11e to 9222ab4 Compare May 15, 2018 20:27
 - The new feature can be used in place of the previous
   CompatiblePowerShellVersion.compatible_version? check

 - The message for DSC_LITE_MODULE_POWERSHELL_UPGRADE_MSG that was
   intended to be shown inside the provider wasn't, since the
   checks made in the type for PowerShell compatibility occurred
   earlier in the Puppet run lifecycle.

 - This prevents duplication of version checks in multiple locations

 - Remove compatible_powershell_version_spec.rb given the code
   has been removed.
@Iristyle Iristyle force-pushed the MODULES-6860-add-dsc_lite-feature-improve-confine-messages branch from 9222ab4 to 4b23deb Compare May 15, 2018 20:34
@RandomNoun7 RandomNoun7 merged commit 914d934 into puppetlabs:master May 15, 2018
@Iristyle Iristyle deleted the MODULES-6860-add-dsc_lite-feature-improve-confine-messages branch May 15, 2018 22:15
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.

None yet

3 participants