Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookbook fails to use reload for restarting dovecot on SLE 12 #16

Closed
kleini opened this issue Sep 10, 2015 · 12 comments

Comments

Projects
None yet
2 participants
@kleini
Copy link

commented Sep 10, 2015

The dovecot cookbook states, that the reload command is supported for all installations of dovecot:

service 'dovecot' do
    supports restart: true, reload: true, status: true
    ....
end

This is not true at least for dovecot on SLE 12 with systemd. There it fails with the following error message:

       - restart service service[postfix]
   Recipe: dovecot::service


       ================================================================================
       Error executing action `reload` on resource 'service[dovecot]'
       ================================================================================

       Mixlib::ShellOut::ShellCommandFailed
       ------------------------------------
       Expected process to exit with [0], but received '3'
       ---- Begin output of /usr/bin/systemctl reload dovecot ----
       STDOUT: 
       STDERR: Failed to reload dovecot.service: Job type reload is not applicable for unit dovecot.service.
       ---- End output of /usr/bin/systemctl reload dovecot ----
       Ran /usr/bin/systemctl reload dovecot returned 3

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cookbooks/dovecot/recipes/service.rb

        22: service 'dovecot' do
        23:   supports restart: true, reload: true, status: true
        24:   if node['platform'] == 'ubuntu' &&
        25:      Gem::Version.new(node['platform_version']) >= Gem::Version.new('13.10')
        26:     provider Chef::Provider::Service::Upstart
        27:   elsif node['platform'] == 'debian' &&
        28:         node['platform_version'].to_i >= 8
        29:     provider Chef::Provider::Service::Debian
        30:   end
        31:   action [:enable, :start]

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cookbooks/dovecot/recipes/service.rb:22:in `from_file'

       service("dovecot") do
         action [:enable, :start]
         updated true
         supports {:restart=>true, :reload=>true, :status=>true}
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         service_name "dovecot"
         enabled true
         running true
         pattern "dovecot"
         declared_type :service
         cookbook_name :dovecot
         recipe_name "service"
       end


   Running handlers:
   [2015-09-10T15:14:14+03:00] ERROR: Running exception handlers
   Running handlers complete
   [2015-09-10T15:14:14+03:00] ERROR: Exception handlers complete
   Chef Client failed. 255 resources updated in 427.081135195 seconds
   [2015-09-10T15:14:14+03:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2015-09-10T15:14:14+03:00] ERROR: service[dovecot] (dovecot::service line 22) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '3'
   ---- Begin output of /usr/bin/systemctl reload dovecot ----
   STDOUT: 
   STDERR: Failed to reload dovecot.service: Job type reload is not applicable for unit dovecot.service.
   ---- End output of /usr/bin/systemctl reload dovecot ----
   Ran /usr/bin/systemctl reload dovecot returned 3
   [2015-09-10T15:14:14+03:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
@zuazo

This comment has been minimized.

Copy link
Owner

commented Sep 10, 2015

Hi @kleini,

Thanks for reporting the issue.

I do not have any machine with SUSE. But trying to run the cookbook on an openSUSE platform gives me a different error:

================================================================================
Error executing action `install` on resource 'zypper_package[(core) dovecot-core]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '104'
---- Begin output of zypper --non-interactive --no-gpg-checks install --auto-agree-with-licenses dovecot-core ----
STDOUT: Loading repository data...
Reading installed packages...
STDERR: Package 'dovecot-core' not found.
---- End output of zypper --non-interactive --no-gpg-checks install --auto-agree-with-licenses dovecot-core ----
Ran zypper --non-interactive --no-gpg-checks install --auto-agree-with-licenses dovecot-core returned 104

Resource Declaration:
---------------------
# In /tmp/kitchen/cookbooks/dovecot/recipes/from_package.rb

 34:     package "(#{type}) #{pkg}" do
 35:       package_name pkg
 36:       only_if { Dovecot::Conf.require?(type, node['dovecot']) }
 37:       if type == 'core' || node['dovecot']['ohai_plugin']['build-options']
 38:         notifies :reload, 'ohai[reload_dovecot]', :immediately
 39:       end
 40:     end # package

Compiled Resource:
       ------------------
# Declared in /tmp/kitchen/cookbooks/dovecot/recipes/from_package.rb:34:in `block (2 levels) in from_file'

zypper_package("(core) dovecot-core") do
  action [:install]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  package_name "dovecot-core"
  declared_type :package
  cookbook_name :dovecot
  recipe_name "from_package"
  only_if { #code block }
end

Please, can you try if disabling the reload fixes the problem on SLE?

@kleini

This comment has been minimized.

Copy link
Author

commented Sep 10, 2015

Obviously they do not have any dovecot-core package:

singlenode:~ # zypper search dovecot
Loading repository data...
Reading installed packages...

S | Name                      | Summary                                                      | Type      
--+---------------------------+--------------------------------------------------------------+-----------
i | dovecot                   | IMAP and POP3 Server Written Primarily with Security in Mind | package   
i | dovecot22                 | IMAP and POP3 Server Written Primarily with Security in Mind | package   
i | dovecot22-backend-mysql   | MySQL support for Dovecot                                    | package   
i | dovecot22-backend-pgsql   | PostgreSQL support for Dovecot                               | package   
i | dovecot22-backend-sqlite  | SQLite support for Dovecot                                   | package   
singlenode:~ # 
@kleini

This comment has been minimized.

Copy link
Author

commented Sep 10, 2015

When I look into the cookbook code I see:

case node['platform']
when 'redhat', 'centos', 'scientific', 'fedora', 'suse', 'amazon', 'oracle'
  default['dovecot']['packages']['core'] = %w(dovecot)
  default['dovecot']['packages']['imap'] = [] # included inside core
  default['dovecot']['packages']['pop3'] = [] # included inside core
  default['dovecot']['packages']['lmtp'] = [] # included inside core
  default['dovecot']['packages']['sieve'] = %w(dovecot-pigeonhole)
  default['dovecot']['packages']['ldap'] = [] # included inside core
  default['dovecot']['packages']['sqlite'] = [] # included inside core
  default['dovecot']['packages']['mysql'] = %w(dovecot-mysql)
  default['dovecot']['packages']['pgsql'] = %w(dovecot-pgsql)

which is correct except the sieve package. I don't see a dovecot-core package for platform suse.

@zuazo

This comment has been minimized.

Copy link
Owner

commented Sep 10, 2015

OK, thanks. I'm going to fix openSUSE support and see if that fixes SUSE support.

@zuazo zuazo added the enhancement label Sep 10, 2015

@zuazo zuazo self-assigned this Sep 10, 2015

@kleini

This comment has been minimized.

Copy link
Author

commented Sep 10, 2015

Is there any chance to workaround the problem by changing attributes in the dovecot service resource to not call the reload function and use instead the restart function?

@zuazo

This comment has been minimized.

Copy link
Owner

commented Sep 10, 2015

You can try disabling the reload in the service after including the cookbook:

include_recipe 'dovecot'

r = resources(service: 'dovecot')
r.supports restart: true, reload: false, status: true
@kleini

This comment has been minimized.

Copy link
Author

commented Sep 11, 2015

Unfortunately the systemd provider does not respect the supports attribute. And we are again here: chef/chef#3678

@zuazo

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2015

I'm on it. Meanwhile try this:

include_recipe 'dovecot'

r = resources(service: 'dovecot')
r.provider(Chef::Provider::Service::Redhat)

zuazo added a commit that referenced this issue Sep 11, 2015

Improve platforms support using platform_family:
* Fix Ubuntu `15.04` support.
* Add SUSE and OpenSUSE support (fixes issue #16).
* Add Oracle Linux support.
* Add Scientific Linux support.
@zuazo

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2015

Fixed in 668f266.

@zuazo zuazo closed this Sep 11, 2015

@zuazo

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2015

Released in 2.4.0.

@kleini

This comment has been minimized.

Copy link
Author

commented Sep 16, 2015

Works like a charm!

@zuazo

This comment has been minimized.

Copy link
Owner

commented Sep 16, 2015

I am glad it has been fixed 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.