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-11123) Avoid loading puppet facts in install/windows.pp #577

Merged
merged 1 commit into from
Aug 30, 2021

Conversation

luchihoratiu
Copy link
Contributor

The install puppet command in manifests/install/windows.pp is executed if the desired version is not already installed. This is done by asking facter the value of the aio_agent_version fact on the target node and is compared to expected package version.

Before this commit, facter was asked to also load puppet facts (using the -p parameter) which was causing high load times due to unnecessary facts getting loaded and resolved when currently installed puppet agent version was the only information needed.

This fix removes the puppet facts loading for this command requirement and lowers catalog application time by as much as half in some scenarios. In our minimal and default environment we got the following output on a Windows node:
❌ Before fix:

puppet agent -t --debug
...
Debug: Exec[prerequisites_check.ps1](provider=windows): Executing 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   C:\Users\ADMINI~1\AppData\Local\Temp\1\prerequisites_check.ps1 6.24.0 C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_02-installer.log'
Debug: Executing: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   C:\Users\ADMINI~1\AppData\Local\Temp\1\prerequisites_check.ps1 6.24.0 C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_02-installer.log'
Notice: /Stage[main]/Puppet_agent::Install::Windows/Exec[prerequisites_check.ps1]/returns: executed successfully (corrective)
Debug: /Stage[main]/Puppet_agent::Install::Windows/Exec[prerequisites_check.ps1]: The container Class[Puppet_agent::Install::Windows] will propagate my refresh event
Debug: Exec[install_puppet.ps1](provider=windows): Executing check 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command {$CurrentVersion = [string](facter.bat -p aio_agent_version);                             if ($CurrentVersion -eq '6.24.0') {                               exit 0;                             }                             exit 1; }.Invoke()'
Debug: Executing: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command {$CurrentVersion = [string](facter.bat -p aio_agent_version);                             if ($CurrentVersion -eq '6.24.0') {                               exit 0;                             }                             exit 1; }.Invoke()'
Debug: Exec[install_puppet.ps1](provider=windows): Executing 'C:\Windows\system32\cmd.exe /S /c start /b C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command C:\Users\ADMINI~1\AppData\Local\Temp\1\install_puppet.ps1                           -PuppetPID 3512                           -Source 'C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi'                           -Logfile 'C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_02-installer.log'                           -InstallDir ''                           -PuppetMaster 'voltaic-mileage.delivery.puppetlabs.net'                           -PuppetStartType 'Automatic'                           -InstallArgs 'REINSTALLMODE="""amus"""'                                                                                 '
Debug: Executing: 'C:\Windows\system32\cmd.exe /S /c start /b C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command C:\Users\ADMINI~1\AppData\Local\Temp\1\install_puppet.ps1                           -PuppetPID 3512                           -Source 'C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi'                           -Logfile 'C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_02-installer.log'                           -InstallDir ''                           -PuppetMaster 'voltaic-mileage.delivery.puppetlabs.net'                           -PuppetStartType 'Automatic'                           -InstallArgs 'REINSTALLMODE="""amus"""'                                                                                 '
Notice: /Stage[main]/Puppet_agent::Install::Windows/Exec[install_puppet.ps1]/returns: executed successfully
...
Notice: Applied catalog in 10.82 seconds

✅ After fix:

puppet agent -t --debug
...
Debug: Exec[prerequisites_check.ps1](provider=windows): Executing 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   C:\Users\ADMINI~1\AppData\Local\Temp\1\prerequisites_check.ps1 6.24.0 C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_07-installer.log'
Debug: Executing: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   C:\Users\ADMINI~1\AppData\Local\Temp\1\prerequisites_check.ps1 6.24.0 C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_07-installer.log'
Notice: /Stage[main]/Puppet_agent::Install::Windows/Exec[prerequisites_check.ps1]/returns: executed successfully (corrective)
Debug: /Stage[main]/Puppet_agent::Install::Windows/Exec[prerequisites_check.ps1]: The container Class[Puppet_agent::Install::Windows] will propagate my refresh event
Debug: Exec[install_puppet.ps1](provider=windows): Executing check 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command {$CurrentVersion = [string](facter.bat aio_agent_version);                             if ($CurrentVersion -eq '6.24.0') {                               exit 0;                             }                             exit 1; }.Invoke()'
Debug: Executing: 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command {$CurrentVersion = [string](facter.bat aio_agent_version);                             if ($CurrentVersion -eq '6.24.0') {                               exit 0;                             }                             exit 1; }.Invoke()'
Debug: Exec[install_puppet.ps1](provider=windows): Executing 'C:\Windows\system32\cmd.exe /S /c start /b C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command C:\Users\ADMINI~1\AppData\Local\Temp\1\install_puppet.ps1                           -PuppetPID 7136                           -Source 'C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi'                           -Logfile 'C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_07-installer.log'                           -InstallDir ''                           -PuppetMaster 'voltaic-mileage.delivery.puppetlabs.net'                           -PuppetStartType 'Automatic'                           -InstallArgs 'REINSTALLMODE="""amus"""'                                                                                 '
Debug: Executing: 'C:\Windows\system32\cmd.exe /S /c start /b C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe                   -ExecutionPolicy Bypass                   -NoProfile                   -NoLogo                   -NonInteractive                   -Command C:\Users\ADMINI~1\AppData\Local\Temp\1\install_puppet.ps1                           -PuppetPID 7136                           -Source 'C:\ProgramData\Puppetlabs\packages\puppet-agent-x64.msi'                           -Logfile 'C:\Users\ADMINI~1\AppData\Local\Temp\1\puppet-2021_08_26-15_07-installer.log'                           -InstallDir ''                           -PuppetMaster 'voltaic-mileage.delivery.puppetlabs.net'                           -PuppetStartType 'Automatic'                           -InstallArgs 'REINSTALLMODE="""amus"""'                                                                                 '
Notice: /Stage[main]/Puppet_agent::Install::Windows/Exec[install_puppet.ps1]/returns: executed successfully
...
Notice: Applied catalog in 5.64 seconds

@luchihoratiu luchihoratiu requested a review from a team August 26, 2021 15:47
@puppet-community-rangefinder
Copy link

puppet_agent::install::windows is a class

that may have no external impact to Forge modules.

This module is declared in 3 of 578 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

The install puppet command in `manifests/install/windows.pp` is executed
if the desired version is not already installed. This is done by asking
facter the value of the `aio_agent_version` fact on the target node and
is compared to expected package version.

Before this commit, facter was asked to also load puppet facts (using
the `-p` parameter) which was causing high load times due to unnecessary
facts getting loaded and resolved when currently installed puppet agent
version was the only information needed.

This fix removes the puppet facts loading for this command requirement
and lowers catalog application time by as much as half in some
scenarios.
@GabrielNagy GabrielNagy merged commit e43b6b4 into puppetlabs:main Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants