[PUP-6459] puppet resource service fails on Windows 10 Pro (x64) Created: 2016/06/29  Updated: 2016/12/05  Resolved: 2016/08/05

Status: Closed
Project: Puppet
Component/s: Windows
Affects Version/s: PUP 4.5.2
Fix Version/s: PUP 4.5.4, PUP 4.6.0

Type: Bug Priority: Blocker
Reporter: Michael Smith Assignee: Erick Banks
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
blocks PCP-513 Acceptance - restart_host_run_puppet.... Resolved
Relates
relates to PUP-1283 Update win32-service gem Closed
Template:
Story Points: 2
Sprint: Windows 2016-08-10
Release Notes: Bug Fix
Release Notes Summary: `puppet resource service` could fail on Windows when there are certain types of delayed auto start services. In particular, it would always fail on Windows 10 due to the `pvhdparser` service.

 Description   

Running puppet resource service on Windows 10 fails with

WARNING: Failed to retreive description for the pvhdparser service.
Error: Could not run: No such device or address - QueryServiceConfig2: The handle is invalid.

This seems to originate in the win32/service gem:

irb(main):001:0> require 'win32/service'
=> true
irb(main):002:0> Win32::Service.services
WARNING: Failed to retreive description for the pvhdparser service.
Errno::ENXIO: No such device or address - QueryServiceConfig2: The handle is invalid.



 Comments   
Comment by Josh Cooper [ 2016/06/29 ]

FWIW, we had a similar issue in PUP-1283 and we patched win32-service gem (https://github.com/djberg96/win32-service/pull/8) to protect against services that don't have a description.

Comment by James Stocks [ 2016/07/28 ]

I think we are also seeing this in pxp-agent's acceptance tests on windows-10ent-32 (32bit)
When I log into the host, any use of "puppet agent resource ..." results in

WARNING: Failed to retreive description for the XboxNetApiSvc service.
                        Error: Could not run: No such device or address - QueryServiceConfig2: The handle is invalid.>

Comment by Ethan Brown [ 2016/07/28 ]

Sorry this one slipped through the cracks. I have also validated that the win32-service gem is at fault.

C:\Users\Parity\Documents\source\00 - Puppet\puppet [master...origin/master]> irb
irb(main):001:0> require 'win32/service'
=> true
irb(main):002:0> Win32::Service.services
WARNING: Failed to retreive description for the pvhdparser service.
Errno::ENXIO: No such device or address - QueryServiceConfig2: The handle is invalid.
        from C:/tools/ruby21/lib/ruby/gems/2.1.0/gems/win32-service-0.8.7/lib/win32/windows/helper.rb:36:in `raise_windows_error'
        from C:/tools/ruby21/lib/ruby/gems/2.1.0/gems/win32-service-0.8.7/lib/win32/service.rb:1380:in `get_config2_info'
        from C:/tools/ruby21/lib/ruby/gems/2.1.0/gems/win32-service-0.8.7/lib/win32/service.rb:1092:in `block in services'
        from C:/tools/ruby21/lib/ruby/gems/2.1.0/gems/win32-service-0.8.7/lib/win32/service.rb:1037:in `upto'
        from C:/tools/ruby21/lib/ruby/gems/2.1.0/gems/win32-service-0.8.7/lib/win32/service.rb:1037:in `services'
        from (irb):2
        from C:/tools/ruby21/bin/irb:11:in `<main>'
irb(main):003:0> exit
C:\Users\Parity\Documents\source\00 - Puppet\puppet [master...origin/master]> gem uninstall win32-service
Successfully uninstalled win32-service-0.8.7

I took a look at the CHANGELOG and changes from 0.8.7 to 0.8.8 and based on the description it looked like this has been fixed - https://github.com/djberg96/win32-service/compare/win32-service-0.8.7...win32-service-0.8.8

I tested quickly on Windows 10 and see that it no longer fails anymore with the 0.8.8 gem:

C:\Users\Parity\Documents\source\00 - Puppet\puppet [master...origin/master]> gem install win32-service --version 0.8.8
Fetching: win32-service-0.8.8.gem (100%)
Successfully installed win32-service-0.8.8
Parsing documentation for win32-service-0.8.8
Installing ri documentation for win32-service-0.8.8
Done installing documentation for win32-service after 0 seconds
1 gem installed
C:\Users\Parity\Documents\source\00 - Puppet\puppet [master...origin/master]> irb
irb(main):001:0> require 'win32/service'
=> true
irb(main):002:0> Win32::Service.services
WARNING: Failed to retrieve description for the pvhdparser service.
WARNING: Unable to get delayed auto start information for the pvhdparser service
WARNING: Unable to retrieve failure actions for the pvhdparser service
WARNING: Failed to retrieve description for the vhdparser service.
WARNING: Unable to get delayed auto start information for the vhdparser service
WARNING: Unable to retrieve failure actions for the vhdparser service
=> [#<struct Struct::ServiceInfo service_name="1394ohci"
 
....
<snip/>

What I've done so far:

I'm marking this as a puppet-agent 1.6.0 blocker since I think these PRs will be pretty straightforward to merge by Monday when we need to discuss the release (which has code freeze next Wednesday)

NOTE: There is a newer 0.8.9 gem, but it is incompatible with Puppet due to namespace collisions for some FFI helper functions.

Comment by Ethan Brown [ 2016/07/28 ]

Also note that when we get the puppet-win32-ruby PRs merged, we should tag new 2.1.x tags for packaging purposes (more necessary if we end up using the old MSI building mechanism instead of Vanagon)

Comment by Moses Mendoza [ 2016/07/29 ]

puppet/stable PR merged at https://github.com/puppetlabs/puppet/commit/2a57218a82b4b60c43ad7f5cb51702b4ffb1125b

Comment by Moses Mendoza [ 2016/07/29 ]

puppet-agent/master PR merged at https://github.com/puppetlabs/puppet-agent/commit/f68c1d6115141ef7f57eccfcc0e696264ba4136e

Comment by Moses Mendoza [ 2016/07/29 ]

puppet-win32-ruby/2.1.x-x64 merged at https://github.com/puppetlabs/puppet-win32-ruby/commit/8da43da0fd93160afec85b86adf67f8e7841e659

Comment by Moses Mendoza [ 2016/07/29 ]

puppet-win32-ruby/2.1.x-x86 merged at https://github.com/puppetlabs/puppet-win32-ruby/commit/c149fb402d4908bbbf028eb13a287b7ec6038f05

Comment by James Stocks [ 2016/07/29 ]

Ethan Brown I submitted a basic acceptance test that would catch this in future:
https://github.com/puppetlabs/puppet/pull/5160

I notice that there are existing tests for user and group; and that they test thoroughly by querying the users or groups natively (e.g. here ) and then comparing the results from 'puppet resource' with the resources found natively. I cannot immediately create such a test for 'resource service' as there isn't an equivalent host.service_list in beaker

Comment by Moses Mendoza [ 2016/07/29 ]

Merged update to puppet-agent/master to have it pull in new puppet-win32-ruby sha(s) for testing purposes https://github.com/puppetlabs/puppet-agent/commit/2f5e83c77fd1b40eb8d0b11a8b78c46165e643b1.

Triggered run of puppet-agent/master pipeline

Comment by Sean McDonald [ 2016/07/29 ]

Puppet-agent jobs started before ~ 11:25 today are going to fail. The win32-service 0.8.8 gem was not available internally on buildsources before then so the windows jobs will fail trying to grab the source. The problem has been remedied and jobs should move forward now.

Comment by Moses Mendoza [ 2016/07/29 ]

Per Sean McDonald we are also going to need to update https://github.com/puppetlabs/puppet-agent/blob/master/resources/patches/rubygem-win32-service/PUP-4390-win32-service-0.8.6-restore_win_2003_compat.patch to apply cleanly with the new gem dep

Comment by Moses Mendoza [ 2016/07/29 ]

Turns out, we can actually just remove that patch since it's for win2003 compatibility

Comment by Ethan Brown [ 2016/08/01 ]

This ran through to completion in puppet CI as part of https://jenkins.puppetlabs.com/view/puppet-agent/view/master/view/puppet/job/platform_puppet_pkg-van-promote_master/278/

However, it has yet to clear through the puppet-agent CI, which is necessary to trigger the new acceptance test on Windows 10, in particular we want this run against the windows10ent-* hosts at this stage -> https://jenkins.puppetlabs.com/view/puppet-agent/view/master/view/puppet-agent/job/platform_puppet-agent_intn-van-sys_suite-daily-puppet-master/175/

Comment by Moses Mendoza [ 2016/08/01 ]

Took a quick look at CI tonight and it appears this hasn't made it through the puppet-agent pipeline yet. As of this comment the last green run of https://jenkins.puppetlabs.com/view/puppet-agent/view/master/view/puppet-agent/job/platform_puppet-agent_intn-van-sys_suite-daily-puppet-master/ was 7/28 and this landed on 7/29

Comment by Moses Mendoza [ 2016/08/04 ]

While all platforms (and thus the overall pipeline) have not passed CI, this specific issue (and windows platforms) have passed.

The successful run output on Windows 10 from the test associated with this issue can be found here: https://jenkins.puppetlabs.com/view/puppet-agent/view/master/view/puppet-agent/job/platform_puppet-agent_intn-van-sys_suite-daily-puppet-master/177/SLAVE_LABEL=beaker,TEST_TARGET=windows10ent-64a/consoleFull

02:38:59         should query all services
02:38:59         
02:38:59         * query with puppet
02:38:59         
02:38:59         rcmu2wmkvf1y9r6.delivery.puppetlabs.net (windows10ent-64-1) 02:38:59$ cmd.exe /c puppet resource service
02:39:04           service { '1394ohci':
02:39:04             ensure => 'stopped',
02:39:04             enable => 'manual',
02:39:04           }
02:39:04           service { '3ware':
02:39:04             ensure => 'stopped',

Comment by Erick Banks [ 2016/08/05 ]

Demoed to me by Moses, James' acceptance test reviewed and is green in CI.

Generated at Sat Aug 24 22:11:01 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.