test-kitchen / test-kitchen

Test Kitchen is an integration tool for developing and testing infrastructure code and software on isolated target platforms
Other
1.87k stars 584 forks source link

'kitchen list' throws NoMethodError if .kitchen/"#{instance_name}".yml is missing `last_action: #{value}` #1118

Open poliva83 opened 8 years ago

poliva83 commented 8 years ago

Description

Got into state where kitchen list kept throwing NoMethodError exception. After investigation it turned out it was because I had empty instance yml file in .kitchen directory (not sure how that file got produced; test-kitchen might have crashed or was aborted). Once file was manually deleted kitchen list worked again.

c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/instance.rb:267:in `last_action': undefined method `[]' for nil:NilClass (NoMethodError)
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/command/list.rb:67:in `display_instance'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/command/list.rb:99:in `block in list_table'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/command/list.rb:99:in `map'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/command/list.rb:99:in `list_table'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/command/list.rb:39:in `call'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/cli.rb:56:in `perform'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/cli.rb:120:in `list'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/cli.rb:326:in `invoke_task'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/bin/kitchen:13:in `block in <top (required)>'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/lib/kitchen/errors.rb:174:in `with_friendly_errors'
        from c:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.11.1/bin/kitchen:13:in `<top (required)>'
        from c:/opscode/chefdk/embedded/bin/kitchen:22:in `load'
        from c:/opscode/chefdk/embedded/bin/kitchen:22:in `<main>'

Kitchen Version

Tell us which version of test-kitchen you are using (kitchen --version).

$ kitchen --version
Test Kitchen version 1.11.1

ChefDK Version

If you are running test-kitchen via ChefDK, chef --version will provide additional relevent version details.

$ chef --version
Chef Development Kit Version: 0.17.17
chef-client version: 12.13.37
delivery version: master (f68e5c5804cd7d8a76c69b926fbb261e1070751b)
berks version: 4.3.5
kitchen version: 1.11.1

Platform Version

Windows 7 Enterprise

Replication Case

  1. Create empty instance yml file in {kitchen_root}/.kitchen/ directory with following content:

    --- 
    ...
  2. Run kitchen list at the kitchen root of test-kitchen project.
cheeseplus commented 8 years ago

We can definitely make the error handling more robust here but generally speaking, if those files get into a bad state then kitchen will barf as it relies on them.