sous-chefs / jenkins

Development repository for the jenkins cookbook
https://supermarket.chef.io/cookbooks/jenkins
Apache License 2.0
424 stars 635 forks source link

jenkins_user and jenkins_view broken in 6.1.0 release #689

Closed kbrowns closed 6 years ago

kbrowns commented 6 years ago

Cookbook version

6.1.0

Chef-client version

14.2.0

Platform Details

awslinux2, fedora28

Scenario:

jenkins_user is broken by the following commit that appears to inadvertently assign the ownership of the jenkins_user resource name to the JenkinsView class.
https://github.com/chef-cookbooks/jenkins/commit/e1242340815932f1ff4c9aaa74d1832dd9ff26b9

Steps to Reproduce:

converge any recipe that uses the jenkins_user resource

Expected Result:

successful compile, converge, and user creation

Actual Result:

Fails with the following error:

================================================================================
         Recipe Compile Error in /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/default.rb
         ================================================================================

         NoMethodError
         -------------
         undefined method `full_name' for Chef::Resource::JenkinsView

         Cookbook Trace:
         ---------------
           /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/service_account_config.rb:31:in `block in from_file'
           /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/service_account_config.rb:30:in `from_file'
           /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/master.rb:14:in `block in from_file'
           /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/master.rb:13:in `each'
           /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/master.rb:13:in `from_file'
           /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/default.rb:1:in `from_file'

         Relevant File Content:
         ----------------------
         /tmp/kitchen/cache/cookbooks/csg_jenkins/recipes/service_account_config.rb:

          24:        "#{rsa_key.ssh_type} #{data}"
          25:      }
          26:      mode '400'
          27:      action :nothing # only fired if the private key file is written above
          28:    end
          29:
          30:    jenkins_user domain_service_account_name do
          31>>     full_name    'Jenkins Admin Service Account'
          32:      email        "#{domain_service_account_name}@csgi.com"
          33:      # must do this lazily to account for scenarios when the files are being written the first time
          34:      public_keys  lazy {
          35:        [::File.read(domain_service_account_pub_pem)]
          36:      }
          37:    end
          38:
          39:    ruby_block 'set-executor-config-post-file-write' do
          40:      block do

         System Info:
         ------------
         chef_version=14.2.0
         platform=amazon
         platform_version=4.14.51-66.38.amzn2.x86_64
         ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
         program_name=/opt/chef/bin/chef-client
         executable=/opt/chef/bin/chef-client

         Running handlers:
       [2018-07-25T14:47:08+00:00] ERROR: Running exception handlers
         Running handlers complete
       [2018-07-25T14:47:08+00:00] ERROR: Exception handlers complete
         Chef Client failed. 1 resources updated in 06 seconds
       [2018-07-25T14:47:08+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2018-07-25T14:47:08+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2018-07-25T14:47:08+00:00] FATAL: NoMethodError: undefined method `full_name' for Chef::Resource::JenkinsView
jayhendren commented 6 years ago

The error I'm getting is very similar, but not quite identical:

      NoMethodError:
        undefined method `public_keys' for Chef::Resource::JenkinsView

I was able to fix it by adding the following to my metadata.rb:

depends 'jenkins', '< 6.1.0'
tas50 commented 6 years ago

the resource_name field in the new resource wasn't updated and this was causing things to load incorrectly. Should be fixed in 6.2 now

jayhendren commented 6 years ago

6.2 works for me!