facebook / chef-cookbooks

Open source chef cookbooks.
Apache License 2.0
569 stars 140 forks source link

Regression with recent log output change #234

Closed taylorific closed 8 months ago

taylorific commented 8 months ago

This change appears to cause a regression if node['fb_apt']['apt_update_log_path'] is not set. https://github.com/facebook/chef-cookbooks/commit/9218cc5e7046da43547d694a411f0ca67ac9cb7e

It seems like the code should have curly braces instead:

execute 'apt-get update' do
  command lazy {
    log_path = node['fb_apt']['apt_update_log_path']
    cmd_suffix = " >>#{Shellwords.shellescape(log_path)} 2>&1" if log_path
    "apt-get update#{cmd_suffix}"
  }
  action :nothing
end

I'm getting the following error with this code when I try to use chef 18: https://github.com/boxcutter/boxcutter-chef-cookbooks/actions/runs/7862940576/job/21452971460

================================================================================
       Recipe Compile Error in /opt/kitchen/cache/cookbooks/boxcutter_init/recipes/default.rb
       ================================================================================

       ArgumentError
       -------------
       tried to create Proc object without a block

       Cookbook Trace: (most recent call first)
       ----------------------------------------
         /opt/kitchen/cache/cookbooks/fb_apt/recipes/default.rb:99:in `block in from_file'
         /opt/kitchen/cache/cookbooks/fb_apt/recipes/default.rb:98:in `from_file'
         /opt/kitchen/cache/cookbooks/boxcutter_init/recipes/default.rb:35:in `from_file'

       Relevant File Content:
       ----------------------
       /opt/kitchen/cache/cookbooks/fb_apt/recipes/default.rb:

        92:  end
        93:  
        94:  fb_apt_sources_list 'populate sources list' do
        95:    notifies :run, 'execute[apt-get update]', :immediately
        96:  end
        97:  
        98:  execute 'apt-get update' do
        99>>   command lazy do
       100:      log_path = node['fb_apt']['apt_update_log_path']
       101:      cmd_suffix = " >>#{Shellwords.shellescape(log_path)} 2>&1" if log_path
       102:      "apt-get update#{cmd_suffix}"
       103:    end
       104:    action :nothing
       105:  end
       106:  
       107:  if Chef::VERSION.to_i >= 16
       108:    notify_group 'periodic package cache update' do

       System Info:
       ------------
       chef_version=18.2.7
       platform=ubuntu
       platform_version=20.04
       ruby=ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
       program_name=/opt/cinc/bin/cinc-client
       executable=/opt/cinc/bin/cinc-client
joshuamiller01 commented 8 months ago

The original author fixed this, working on getting it merged now.

taylorific commented 8 months ago

Awesome - thanks Adam and all.

joshuamiller01 commented 8 months ago

I manually fixed this, should be gtg.