Skip to content

Invalid rescue in resources/connector.rb:166

Hi

It seems that v3.4.0 passed the pipelines, however when I execute it locally using Chef v13.12.14 I get this error.

================================================================================
Recipe Compile Error in /var/cache/chef/cookbooks/confluent-platform/resources/connector.rb
================================================================================

SyntaxError
-----------
/var/cache/chef/cookbooks/confluent-platform/resources/connector.rb:166: syntax error, unexpected keyword_rescue, expecting keyword_end
  rescue StandardError # Errno::EADDRN
        ^
/var/cache/chef/cookbooks/confluent-platform/resources/connector.rb:170: syntax error, unexpected keyword_end, expecting end-of-input

System Info:
------------
chef_version=13.12.14
platform=ubuntu
platform_version=16.04
ruby=ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
program_name=chef-client worker: ppid=14654;start=13:34:42;
executable=/opt/chef/bin/chef-client

Looking at resources/connector.rb I suspect that the wait_url() should have a begin/end block inside the times loop. But don't take my word for it, I'm no ruby expert.

This works for me, but I don't use this part of the code, so it's hard for me to test.

def wait_url(url, waits, waits_delay)
  waits.times do |i|
    begin
      call_api(url, '')
      break
    rescue StandardError # Errno::EADDRNOTAVAIL + error code
      Chef::Log.info("Connectors: waiting for #{url} (#{i}/#{waits}")
      sleep(waits_delay)
    end
  end
end