sous-chefs / consul

Development repository for the consul cookbook
https://supermarket.chef.io/cookbooks/consul
Apache License 2.0
192 stars 244 forks source link

Can't enable or reload service #412

Closed matkam closed 7 years ago

matkam commented 7 years ago

Started getting this error recently, possibly due to using a newer version of poise-service. Using Consul recipe 2.3.0, running on Ubuntu 14.04:

  * consul_service[consul] action enable
    * directory[/var/lib/consul] action create (up to date)
    * poise_service[consul] action enable
      * template[/etc/init/consul.conf] action create (up to date)
      * service[consul] action enable

        ================================================================================                                                                                                                                  Error executing action `enable` on resource 'service[consul]'                                                                                                                                                     ================================================================================                                                                                                                                                                                                                                                                                                                                                    NoMethodError                                                                                                                                                                                                     -------------                                                                                                                                                                                                     undefined method `[]' for nil:NilClass                                                                                                                                                                                                                                                                                                                                                                                              Cookbook Trace:                                                                                                                                                                                                   ---------------                                                                                                                                                                                                   /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:122:in `block in enable_service'                                                                                 /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:134:in `notify_if_service'                                                                                       /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:121:in `enable_service'                                                                                          /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:60:in `action_enable'                                                                                            /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:89:in `block in action_enable'                                                                                            /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:154:in `notify_if_service'                                                                                                /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:88:in `action_enable'                                                                                                     /var/chef/cache/cookbooks/consul/libraries/consul_service.rb:80:in `action_enable'                                                                                                                                                                                                                                                                                                                                                  Resource Declaration:                                                                                                                                                                                             ---------------------                                                                                                                                                                                             # In /var/chef/cache/cookbooks/consul/recipes/default.rb                                                                                                                                                                                                                                                                                                                                                                             53: consul_service service_name do |r|                                                                                                                                                                            54:   version node['consul']['version']                                                                                                                                                                           55:   config_file config.path                                                                                                                                                                                     56:   program install.consul_program                                                                                                                                                                              57:                                                                                                                                                                                                               58:   unless windows?                                                                                                                                                                                             59:     user node['consul']['service_user']                                                                                                                                                                       60:     group node['consul']['service_group']                                                                                                                                                                     61:   end                                                                                                                                                                                                         62:   if node['consul']['service']                                                                                                                                                                                                                                                                                                                                                                                                 Compiled Resource:                                                                                                                                                                                                ------------------                                                                                                                                                                                                # Declared in /var/chef/cache/cookbooks/consul/recipes/default.rb:53:in `from_file'                                                                                                                                                                                                                                                                                                                                                 service("consul") do                                                                                                                                                                                                provider Chef::Provider::Service::Upstart                                                                                                                                                                         action [:nothing]                                                                                                                                                                                                 supports {:status=>true, :restart=>true, :reload=>true}
          retries 0                                                                                                                                                                                                         retry_delay 2                                                                                                                                                                                                     default_guard_interpreter :default                                                                                                                                                                                service_name "consul"                                                                                                                                                                                             pattern "consul"                                                                                                                                                                                                end                                                                                                                                                                                                                                                                                                                                                                                                                                 Platform:                                                                                                                                                                                                         ---------                                                                                                                                                                                                         x86_64-linux                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

                                                                                                                                                                                                                        ================================================================================                                                                                                                                  Error executing action `enable` on resource 'poise_service[consul]'                                                                                                                                               ================================================================================                                                                                                                                                                                                                                                                                                                                                    NoMethodError                                                                                                                                                                                                     -------------                                                                                                                                                                                                     service[consul] (/var/chef/cache/cookbooks/consul/recipes/default.rb line 53) had an error: NoMethodError: undefined method `[]' for nil:NilClass

      Cookbook Trace:
      ---------------
      /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:122:in `block in enable_service'
      /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:134:in `notify_if_service'
      /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:121:in `enable_service'
      /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:60:in `action_enable'
      /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:89:in `block in action_enable'
      /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:154:in `notify_if_service'
      /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:88:in `action_enable'
      /var/chef/cache/cookbooks/consul/libraries/consul_service.rb:80:in `action_enable'

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/consul/recipes/default.rb

       53: consul_service service_name do |r|
       54:   version node['consul']['version']
       55:   config_file config.path
       56:   program install.consul_program
       57:
       58:   unless windows?
       59:     user node['consul']['service_user']
       60:     group node['consul']['service_group']
       61:   end
       62:   if node['consul']['service']

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/consul/recipes/default.rb:53:in `from_file'

      poise_service("consul") do
        action [:enable]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        user "consul"
        command "/opt/consul/0.6.4/consul agent -config-file=/etc/consul/consul.json -config-dir=/etc/consul/conf.d"
        stop_signal "TERM"
        reload_signal "HUP"
        service_name "consul"
        directory "/var/lib/consul" 
        environment {"GOMAXPROCS"=>"4", "PATH"=>"/usr/local/bin:/usr/bin:/bin"}
        options_systemd {"template"=>"consul:systemd.service.erb"}
        options_sysvinit {"template"=>"consul:sysvinit.service.erb"}
        options_upstart {"template"=>"consul:upstart.service.erb", "executable"=>"/opt/consul/0.6.4/consul"}
      end

      Platform:
      ---------
      x86_64-linux

    ================================================================================
    Error executing action `enable` on resource 'consul_service[consul]'
    ================================================================================

    NoMethodError
    -------------
    poise_service[consul] (/var/chef/cache/cookbooks/consul/recipes/default.rb line 53) had an error: NoMethodError: service[consul] (/var/chef/cache/cookbooks/consul/recipes/default.rb line 53) had an error: NoMethodError: undefined method `[]' for nil:NilClass                                                                                                                                                               
    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:122:in `block in enable_service'
    /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:134:in `notify_if_service'
    /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:121:in `enable_service'
    /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_providers/base.rb:60:in `action_enable'
    /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:89:in `block in action_enable'
    /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:154:in `notify_if_service'
    /var/chef/cache/cookbooks/poise-service/files/halite_gem/poise_service/service_mixin.rb:88:in `action_enable'
    /var/chef/cache/cookbooks/consul/libraries/consul_service.rb:80:in `action_enable'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/consul/recipes/default.rb

     53: consul_service service_name do |r|
     54:   version node['consul']['version']
     55:   config_file config.path  
     56:   program install.consul_program
     57:
     58:   unless windows?
     59:     user node['consul']['service_user']
     60:     group node['consul']['service_group']
     61:   end
     62:   if node['consul']['service']

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/consul/recipes/default.rb:53:in `from_file'

    consul_service("consul") do
      action [:enable]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :consul_service 
      cookbook_name "consul"
      recipe_name "default"
      config_file "/etc/consul/consul.json"
      program "/opt/consul/0.6.4/consul"
      user "consul"
      group "consul"
      config_dir "/etc/consul/conf.d"
      nssm_params {"AppDirectory"=>"/var/lib/consul", "AppStdout"=>"/etc/consul/stdout.log", "AppStderr"=>"/etc/consul/error.log", "AppRotateFiles"=>1, "AppRotateOnline"=>1, "AppRotateBytes"=>20000000}
      data_dir "/var/lib/consul"
      service_name "consul"
      environment {"GOMAXPROCS"=>"4", "PATH"=>"/usr/local/bin:/usr/bin:/bin"}
    end

    Platform:
    ---------
    x86_64-linux
matkam commented 7 years ago

Turns out this was happening because the Consul was having trouble starting up due to configuration issues.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.