rtkwlf / cookbook-simple-iptables

Simple Chef iptables cookbook
85 stars 63 forks source link

Runtime errors under Chef 13 client #83

Open briancline opened 7 years ago

briancline commented 7 years ago

I'm seeing a runtime error when attempting to use this under any Chef 13 client. The below occurs under a simple Ubuntu 14.04 VM under Test Kitchen:

       Recipe: simple_iptables::default
         * apt_package[iptables] action install (up to date)
         * ruby_block[run-iptables-resources-early] action run

           ================================================================================
           Error executing action `run` on resource 'ruby_block[run-iptables-resources-early]'
           ================================================================================

           NameError
           ---------
           uninitialized constant Chef::Resource::SimpleIptablesRule

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/simple_iptables/recipes/default.rb:41:in `block (3 levels) in from_file'
           /tmp/kitchen/cache/cookbooks/simple_iptables/recipes/default.rb:40:in `block (2 levels) in from_file'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/simple_iptables/recipes/default.rb

            34: ruby_block "run-iptables-resources-early" do
            35:   block do
            36:     # Clear old normal-level attributes set by previous versions of the cookbook
            37:     node.rm_normal("simple_iptables", "ipv4")
            38:     node.rm_normal("simple_iptables", "ipv6")
            39:     # Then run all the simple_iptables_* resources
            40:     run_context.resource_collection.each do |resource|
            41:       if resource.kind_of?(Chef::Resource::SimpleIptablesRule)
            42:         Chef::Log.debug("about to run simple_iptables_rule[#{resource.chain}]")
            43:         resource.run_action(resource.action)
            44:       elsif resource.kind_of?(Chef::Resource::SimpleIptablesPolicy)
            45:         Chef::Log.debug("about to run simple_iptables_policy[#{resource.chain}]")
            46:         resource.run_action(resource.action)
            47:       end
            48:     end
            49:
            50:     Chef::Log.debug("After run-iptables-resources-early data is: #{node['simple_iptables']}")
            51:   end
            52: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/simple_iptables/recipes/default.rb:34:in `from_file'

           ruby_block("run-iptables-resources-early") do
             action [:run]
             default_guard_interpreter :default
             block_name "run-iptables-resources-early"
             declared_type :ruby_block
             cookbook_name "simple_iptables"
             recipe_name "default"
             block #<Proc:0x00000004a97460@/tmp/kitchen/cache/cookbooks/simple_iptables/recipes/default.rb:35>
           end

           System Info:
           ------------
           chef_version=13.0.118
           platform=ubuntu
           platform_version=14.04
           ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
           program_name=chef-client worker: ppid=27618;start=22:51:20;
           executable=/opt/chef/bin/chef-client

       Running handlers:
       [2017-04-17T22:51:23+00:00] ERROR: Running exception handlers
       [2017-04-17T22:51:23+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2017-04-17T22:51:23+00:00] ERROR: Exception handlers complete
       [2017-04-17T22:51:23+00:00] ERROR: Exception handlers complete
       Chef Client failed. 19 resources updated in 02 seconds
       [2017-04-17T22:51:23+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2017-04-17T22:51:23+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2017-04-17T22:51:23+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2017-04-17T22:51:23+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2017-04-17T22:51:23+00:00] ERROR: ruby_block[run-iptables-resources-early] (simple_iptables::default line 34) had an error: NameError: uninitialized constant Chef::Resource::SimpleIptablesRule
       [2017-04-17T22:51:23+00:00] ERROR: ruby_block[run-iptables-resources-early] (simple_iptables::default line 34) had an error: NameError: uninitialized constant Chef::Resource::SimpleIptablesRule
       [2017-04-17T22:51:23+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
       [2017-04-17T22:51:23+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
rtkrruvinskiy commented 7 years ago

I have not had the chance to try with Chef Client 13, but it looks like Chef Client changes in that release are incompatible with our hack to control when the resources converge. I will try to investigate this, but any community help here will be more than welcome!

jeunito commented 7 years ago

@rtkrruvinskiy I made a PR here https://github.com/rtkwlf/cookbook-simple-iptables/pull/84 but it's failing on the "mangle" rules. I haven't figured out why.