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

File resource is trying to load Windows provider on a non-Windows computer #68

Open
glennsarti opened this issue Feb 26, 2018 · 2 comments

Comments

@glennsarti
Copy link

With v1.9.0 having better Windows support, it has exposed a possible issue with loading providers.

In the puppet_agent module, running https://github.com/puppetlabs/puppetlabs-puppet_agent/blob/master/spec/classes/puppet_agent_spec.rb with v 1.8.0 of rspec-puppet-facts gem, they pass correctly.

When I run with v1.9.0 I get errrors such as;

  8) puppet_agent supported operating systems on ubuntu-16.04-x86_64 puppet_agent class without any parameters should compile into a catalogue without dependency cycles
     Failure/Error: it { is_expected.to compile.with_all_deps }

     NoMethodError:
       undefined method `supports_acl?' for File[sources.list](provider=windows):Puppet::Type::File::ProviderWindows
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/provider/file/windows.rb:84:in `validate'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/type/file.rb:394:in `block (2 levels) in <top (required)>'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/type.rb:2402:in `initialize'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/type/file.rb:491:in `initialize'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/resource.rb:461:in `new'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/resource.rb:461:in `to_ral'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/resource/catalog.rb:640:in `block in to_catalog'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/resource/catalog.rb:632:in `each'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/resource/catalog.rb:632:in `to_catalog'
     # /usr/local/bundle/gems/puppet-5.4.0/lib/puppet/resource/catalog.rb:513:in `to_ral'
     # /usr/local/bundle/gems/rspec-puppet-2.6.9/lib/rspec-puppet/matchers/compile.rb:142:in `cycles_found?'
     # /usr/local/bundle/gems/rspec-puppet-2.6.9/lib/rspec-puppet/matchers/compile.rb:25:in `matches?'
     # ./spec/classes/puppet_agent_spec.rb:154:in `block (7 levels) in <top (required)>'

Note that it's trying to load the Windows File resource provider.

So what I did was run ONLY ubuntu-16.04-x86_64 tests and they pass. If the Windows tests run prior they fail with error above.

It appears that the first invocation is determining the default provider.

To test this I changed:
https://github.com/puppetlabs/puppetlabs-puppet_agent/blob/master/spec/classes/puppet_agent_spec.rb#L75

to (ubuntu only)

context "on #{os}", :if => (os == 'ubuntu-16.04-x86_64') do

to (windows -> windows -> ubuntu)

context "on #{os}", :if => (os == 'windows-2008 R2-x64' || os == 'windows-2012-x64' || os == 'ubuntu-16.04-x86_64') do

Environment:
Docker on Windows
Linux bdf55e700bbe 4.9.60-linuxkit-aufs #1 SMP Mon Nov 6 16:00:12 UTC 2017 x86_64 GNU/Linux

Puppet facts

root@bdf55e700bbe:/project# bundle exec puppet facts
{
  "name": "bdf55e700bbe.gallifrey.local",
  "values": {
    "puppetversion": "5.4.0",
    "kernel": "Linux",
    "kernelrelease": "4.9.60-linuxkit-aufs",
    "facterversion": "2.5.1",
    "partitions": {
      "sda1": {
        "size": "125827072",
        "mount": "/etc/resolv.conf"
      }
    },
    "operatingsystem": "Debian",
    "domain": "gallifrey.local",
    "operatingsystemmajrelease": "8",
    "timezone": "UTC",
    "selinux": false,
    "uptime_days": 0,
    "physicalprocessorcount": 1,
    "os": {
      "name": "Debian",
      "family": "Debian",
      "release": {
        "major": "8",
        "minor": "8",
        "full": "8.8"
      }
    },
    "rubyplatform": "x86_64-linux",
    "virtual": "docker",
    "is_virtual": true,
    "architecture": "amd64",
    "hardwaremodel": "x86_64",
    "uptime_hours": 3,
    "processors": {
      "models": [
        "Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz",
        "Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz"
      ],
      "count": 2,
      "physicalcount": 1
    },
    "processor0": "Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz",
    "processor1": "Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz",
    "processorcount": 2,
    "interfaces": "",
    "ipaddress": "172.17.0.2",
    "osfamily": "Debian",
    "operatingsystemrelease": "8.8",
    "kernelmajversion": "4.9",
    "rubysitedir": "/usr/local/lib/ruby/site_ruby/2.1.0",
    "uptime_seconds": 11444,
    "fqdn": "bdf55e700bbe.gallifrey.local",
    "filesystems": "ext2,ext3,ext4,iso9660,msdos,squashfs,udf,vfat,xfs",
    "uniqueid": "11ac0200",
    "path": "/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "blockdevice_sr0_size": 443424768,
    "blockdevice_sr0_vendor": "Msft",
    "blockdevice_sr0_model": "Virtual DVD-ROM",
    "blockdevice_sda_size": 64424509440,
    "blockdevice_sda_vendor": "Msft",
    "blockdevice_sda_model": "Virtual Disk",
    "blockdevice_sr1_size": 174080,
    "blockdevice_sr1_vendor": "Msft",
    "blockdevice_sr1_model": "Virtual DVD-ROM",
    "blockdevices": "sda,sr0,sr1",
    "gid": "root",
    "system_uptime": {
      "seconds": 11444,
      "hours": 3,
      "days": 0,
      "uptime": "3:10 hours"
    },
    "hostname": "bdf55e700bbe",
    "rubyversion": "2.1.10",
    "kernelversion": "4.9.60",
    "ps": "ps -ef",
    "memorysize": "1.93 GB",
    "memoryfree": "1.53 GB",
    "swapsize": "1024.00 MB",
    "swapfree": "1023.83 MB",
    "swapsize_mb": "1024.00",
    "swapfree_mb": "1023.83",
    "memorysize_mb": "1980.77",
    "memoryfree_mb": "1565.25",
    "hardwareisa": "unknown",
    "id": "root",
    "uptime": "3:10 hours",
    "clientcert": "bdf55e700bbe.gallifrey.local",
    "clientversion": "5.4.0",
    "clientnoop": false
  },
  "timestamp": "2018-02-26T06:52:36.884490600+00:00",
  "expiration": "2018-02-26T07:22:36.884672700+00:00"
}
glennsarti added a commit to glennsarti/puppetlabs-puppet_agent that referenced this issue Feb 26, 2018
Previously many tests in classes/puppet_agent_spec.rb were not running on
Windows due to a bug in rspec-puppet-facts.  However in v1.9.0 of the gem it
now adds better windows support, but the puppet_agent_spec.rb began running
tests for Windows which then failed.  This commit modifies the test fixtures and
logic to only test things which make sense on Windows.

Also voxpupuli/rspec-puppet-facts#68 meant that the
order of the testing had to be determinstic, ensuring that Windows platforms
were tested last.
glennsarti added a commit to glennsarti/puppetlabs-puppet_agent that referenced this issue Feb 26, 2018
Previously many tests in classes/puppet_agent_spec.rb were not running on
Windows due to a bug in rspec-puppet-facts.  However in v1.9.0 of the gem it
now adds better windows support, but the puppet_agent_spec.rb began running
tests for Windows which then failed.  This commit modifies the test fixtures and
logic to only test things which make sense on Windows.

Also voxpupuli/rspec-puppet-facts#68 meant that the
order of the testing had to be determinstic, ensuring that Windows platforms
were tested last.
@ghoneycutt
Copy link
Member

@glennsarti is this still an issue or was it fixed by MODULES-6686 ?

@glennsarti
Copy link
Author

Wasn't really fixed MODULES-6686. It just added a bunch of guards.

In particular, there's still a workaround in place for this issue

https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/275/files#diff-dd7937600c4fa756c1d8e06ddbcf61e9R84

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

No branches or pull requests

2 participants