(PUP-10653) Remove Dir monkey patch#8314
Conversation
|
Some background, we started using Puppet modules/extensions/code often needs to know where the https://github.com/puppetlabs/puppet-enterprise-modules/blob/64f37498654d8c1f20aeb3e48875777e4bfaad3a/modules/puppet_enterprise/lib/facter/windows.rb#L5 So I'm a little reluctant to remove that constant entirely... Maybe remove the overall win32/dir gem monkey patch and define the A few things to watch out for though. The We had issues due to that difference (fixed in 6767686, aa67f14). We might need to check if there are any calls to Another place this might cause issues is |
|
CLA signed by all contributors. |
|
Since almost all the places that access the constant also require Bolt as a gem will probably need to have an explicit dependency on the gem, while packaged Bolt will still work as their runtime includes the win32 gems: https://github.com/puppetlabs/puppet-runtime/blob/26a3d6eaf8f1ef750e73d785583a60c48a7495ec/configs/projects/bolt-runtime.rb#L197. I think it's gnarlier if we keep the monkey patch and another project requires |
bc0af0f to
36f0f77
Compare
|
Ok, I went through all the places where we call
About 6767686 and aa67f14 don't cause any breakage after removing the monkey patched code, but I'd still revert them to avoid eventual confusion. Thoughts @joshcooper? |
| @LOG_TO_FILE = false | ||
| @loglevel = 0 | ||
| LOG_FILE = File.expand_path(File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'puppet', 'var', 'log', 'windows.log')) | ||
| LOG_FILE = File.expand_path(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs', 'puppet', 'var', 'log', 'windows.log')) |
There was a problem hiding this comment.
If the service is configured to run under a domain service account, would COMMON_APPDATA be different than ALLUSERSPROFILE? I assume not, but wanted to check
There was a problem hiding this comment.
I set up a domain controller and client, set the puppet service to run as a domain account and confirmed that COMMON_APPDATA and ALLUSERSPROFILE are the same.
|
👍 to reverting the commits above to avoid confusion |
|
I reverted the |
joshcooper
left a comment
There was a problem hiding this comment.
LGTM. There's a conflict that needs resolving. Also could you run with pr tests on 32 and 64 bit Windows?
Remove usage of CSIDL Dir constants and replace them with environment variables. Dir::PROFILE -> ENV['USERPROFILE'] Dir::COMMON_APPDATA -> ENV['ALLUSERSPROFILE'] Dir::WINDOWS -> ENV['SystemRoot'] Remove requires to the Dir monkey patch.
This reverts commit 6767686. As we are removing the Dir (win32/dir) monkeypatches, this workaround is no longer needed.
1f88d56 to
63c6020
Compare
|
jenkins please test this on windows10ent-64,windows10ent-32,windows2012r2-64,windows2016-64,windows2019-64,windows2012-64,windows2012r2-64,windows2012r2_wmf5-64,windows2012r2_core-64,windows7-64,windows81-64,windows10ent-32,windows10ent-32,windows2016-64,windows2016_core-64,windows2019_core-64,windows2019_ja-64a |
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking when using the stdlib module with Puppet 7, as the win32 dependencies are no longer provided in the puppet gem. Replace the usage of the `Dir::COMMON_APPDATA` with the `ALLUSERSPROFILE` environment variable.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking in bolt when it switches to Puppet 7 and the win32 gems are no longer pulled. For AIO bolt, the Puppet change won't break anything since bolt uses its own runtime which still packages the win32 gems, but it would still be an improvement in speed if the dependency is dropped. The `win32/dir` gem also monkey patches some `Dir` methods, most notably `glob` and `pwd` to use backslashes which end up causing more trouble as Ruby uses `/` as the default separator for Windows. Switch to using the `ALLUSERSPROFILE` environment variable instead of the `Dir::COMMON_APPDATA` constant, and remove a `Dir.pwd` workaround. !removal * **Remove dependency on win32/dir** ([PUP-10653](https://tickets.puppetlabs.com/browse/PUP-10653)) Replace the usage of win32/dir constants with environment variables.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking when using the stdlib module with Puppet 7, as the win32 dependencies are no longer provided in the puppet gem. Replace the usage of the `Dir::COMMON_APPDATA` with the `ALLUSERSPROFILE` environment variable.
For Puppet 7 we are dropping the `win32/dir` dependency as we only used constants from it, which we replaced with environment variables (see: puppetlabs/puppet#8314). This would become breaking when using the stdlib module with Puppet 7, as the win32 dependencies are no longer provided in the puppet gem. Replace the usage of the `Dir::COMMON_APPDATA` with the `ALLUSERSPROFILE` environment variable.
We removed our external dependency on the win32-dir gem in #8258 by pulling the gem code in puppet. However, it seems that win32-dir features are not used outside of constants which can all be replaced by environment variables. Do that, and remove the monkey patched code.