httpd icon indicating copy to clipboard operation
httpd copied to clipboard

httpd-default restart at every chef-client run

Open pdion891 opened this issue 8 years ago • 2 comments

Cookbook version

httpd (0.6.1)

Chef-client version

12.21.31

Platform Details

CentOS 7.4 using kitchen-cloudstack

Scenario:

When using the default deployement scenario:

httpd_service 'default' do
  action [:create, :start]
end

httpd_config 'default' do
  source 'mysite.cnf.erb'
  notifies :restart, 'httpd_service[default]'
  action :create
end

The service 'httpd-default' is restarted at every chef-client run.

Steps to Reproduce:

Everytime chef-client is executed using kitchen converge on CentOS 7 the service httpd-default is restarted.

[root@VM-2cbead58-53f3-46d0-a93a-7721f19259c0 cca-user]# systemctl status httpd-default
● httpd-default.service - The Apache HTTP Server
   Loaded: loaded (/etc/systemd/system/httpd-default.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2018-01-06 13:26:29 EST; 1min 49s ago
 Main PID: 9303 (httpd-default)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd-default.service
           ├─9303 /usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -DFOREGROUND
           ├─9304 /usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -DFOREGROUND
           ├─9305 /usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -DFOREGROUND
           └─9306 /usr/sbin/httpd-default -f /etc/httpd-default/conf/httpd.conf -DFOREGROUND

1min 49s ago

to test the behavior, download a large file from apache, then run chef-client or kitchen converge then the download fail because of the restart of httpd.

Expected Result:

When there is not configuration change as this example, the service should not be restart automatically or event reload. If 'reload' is specified in httpd_config then the service should be reload, not restart.

Actual Result:

This service restart kill all existing connections to httpd.

pdion891 avatar Jan 06 '18 18:01 pdion891

@tas50: I have just been informed that we have been having this issue, as well. Would you please revert 6fc1a7dcb454df8a9a98b45a1eb8c2127d01b5be and push a minor update to supermarket. The previous code was correct. That function is supposed to make sure that the default service (httpd) is not running, not stop the service the cookbook is configuring (httpd-#{instance}). The later is resulting in a stop and start of every httpd_service resource with every chef run.

karmix avatar Jan 25 '18 23:01 karmix

It seems that @karmix is correct. From my chef-client runs on httpd (0.6.2) the :create action cause the service to stop, disable then the :start action causes it to start and enable.

httpd_service 'default' do
  action [:create, :start]
end
 httpd_service_rhel_systemd[default] action create
    * yum_package[httpd] action install (up to date)
    * service[httpd-default] action stop
      - stop service service[httpd-default]
    * service[httpd-default] action disable
      - disable service service[httpd-default]

  * httpd_service_rhel_systemd[default] action start
    * service[httpd-default] action start
      - start service service[httpd-default]
    * service[httpd-default] action enable
      - enable service service[httpd-default]

wahlstedtw avatar May 16 '18 19:05 wahlstedtw