Jira (PUP-11459) Puppet::Util::Windows is undefined on non-Windows platforms

28 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Feb 17, 2022, 11:48:01 PM2/17/22
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-11459
Puppet::Util::Windows is undefined on non-Windows platforms
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2022/02/17 8:47 PM
Priority: Normal Normal
Reporter: Josh Cooper

The file lib/puppet/util/windows.rb defines a set of constants that should be available on all platforms, such as {Puppet::Util::Windows, {Puppet::Util::Windows::Service and Puppet::Util::Windows::Service::DEFAULT_TIMEOUT.

It also requires Windows-specific code that is only safe to load on Windows, because the code tries to load native libraries, such as user32.dll.

The problem is when puppet is running on a non-Windows platform, then lib/puppet/util/windows.rb is never loaded. As a result, trying to test a service resource using rspec-puppet fails when trying to reference the Puppet::Util::Windows constant. See PDK-1760 for steps to reproduce.

A quicker reproduction is:

 bx ruby -e "require 'puppet'; puts Puppet::Util::Windows"
Traceback (most recent call last):
-e:1:in `<main>': uninitialized constant Puppet::Util::Windows (NameError)

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Josh Cooper (Jira)

unread,
Feb 18, 2022, 12:20:02 AM2/18/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
The file {{lib/puppet/util/windows.rb}} defines a set of constants that should be available on all platforms, such as {{{Puppet::Util::Windows}}, {{{Puppet::Util::Windows::Service}} and {{Puppet::Util::Windows::Service::DEFAULT_TIMEOUT}}.

It also requires Windows-specific code that is only safe to load on Windows, because the code tries to load native libraries, such as {{user32.dll}}.


The problem is when puppet is running on a non-Windows platform, then {{lib/puppet/util/windows.rb}} is never loaded. As a result, trying to test a {{service}} resource using rspec-puppet fails when trying to reference the {{Puppet::Util::Windows}} constant. See PDK-1760 for steps to reproduce.

A quicker reproduction is:

{code}
bx $ bundle exec ruby -e "require 'puppet'; puts Puppet::Util::Windows"

Traceback (most recent call last):
-e:1:in `<main>': uninitialized constant Puppet::Util::Windows (NameError)
{code}

Josh Cooper (Jira)

unread,
Feb 18, 2022, 12:21:01 AM2/18/22
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Feb 18, 2022, 12:21:02 AM2/18/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 7.15.0
Fix Version/s: PUP 6.27.0

Josh Cooper (Jira)

unread,
Feb 18, 2022, 10:44:02 AM2/18/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
The file {{lib/puppet/util/windows.rb}} defines a set of constants that should be available on all platforms, such as {{ { Puppet::Util::Windows}}, {{ {
Puppet::Util::Windows::Service}} and {{Puppet::Util::Windows::Service::DEFAULT_TIMEOUT}}.


It also requires Windows-specific code that is only safe to load on Windows, because the code tries to load native libraries, such as {{user32.dll}}.

The problem is when puppet is running on a non-Windows platform, then {{lib/puppet/util/windows.rb}} is never loaded. As a result, trying to test a {{service}} resource using rspec-puppet fails when trying to reference the {{Puppet::Util::Windows}} constant. See PDK-1760 for steps to reproduce.

A quicker reproduction is:

{code}
$ bundle exec ruby -e "require 'puppet'; puts Puppet::Util::Windows"
Traceback (most recent call last):
-e:1:in `<main>': uninitialized constant Puppet::Util::Windows (NameError)
{code}

Nirupama Mantha (Jira)

unread,
Feb 22, 2022, 4:10:01 PM2/22/22
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Feb 23, 2022, 8:56:03 PM2/23/22
to puppe...@googlegroups.com

Austin Boyd (Jira)

unread,
Feb 25, 2022, 7:03:02 PM2/25/22
to puppe...@googlegroups.com
Austin Boyd updated an issue
Change By: Austin Boyd
Zendesk Ticket Count: 1
Zendesk Ticket IDs: 47102

Austin Boyd (Jira)

unread,
Feb 25, 2022, 7:03:03 PM2/25/22
to puppe...@googlegroups.com

Nirupama Mantha (Jira)

unread,
Mar 2, 2022, 11:55:02 AM3/2/22
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Mar 2, 2022, 8:31:03 PM3/2/22
to puppe...@googlegroups.com
Josh Cooper assigned an issue to Unassigned
Change By: Josh Cooper
Assignee: Josh Cooper

Josh Cooper (Jira)

unread,
Mar 8, 2022, 6:26:01 PM3/8/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: Fixes a bug that prevented pdk unit tests from working when trying to test a resource with a Windows provider, such as "service" resources.

Parker Leach (Jira)

unread,
Mar 14, 2022, 12:53:01 PM3/14/22
to puppe...@googlegroups.com
Parker Leach updated an issue
Change By: Parker Leach
Labels: doc_reviewed jira_escalated

Parker Leach (Jira)

unread,
Mar 15, 2022, 1:47:01 PM3/15/22
to puppe...@googlegroups.com
Parker Leach updated an issue
Change By: Parker Leach
Labels: doc_reviewed docs_reviewed jira_escalated
Reply all
Reply to author
Forward
0 new messages