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

Service resource is not working as expected not able to detect service status in why-run #8556

Open
Vasusanghave opened this issue May 16, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@Vasusanghave
Copy link

commented May 16, 2019

CHEF CLIENT BUG: Service resource giving invalid message in why-run mode and its not able to determine the status of the service:
*** Service status not available. Assuming a prior action would have installed the service.
* Assuming status of not running.**


Description

In default recipe, we have called the service resource with attributes as shown below :
service 'crond' do
provider ::Chef::Provider::Service::Systemd if RHEL_7_OR_HIGHER
action [:start, :enable]
end

where, RHEL_7_OR_HIGHER is boolean value. RHEL_7_OR_HIGHER will be true if RHEL version is 7 or higher else it's false.

When executing policy in why-run mode, facing the below issue :

For action start & enable for crod service, we are getting warning/message as below and its not able to determine the service status :
" * Service status not available. Assuming a prior action would have installed the service.
* Assuming status of not running. "
in both the cases.
i.e 1. when crond service is already started or enabled on node(This means node is already in 'complaint/up-to-date' state)
2. when service is not started or enabled on node(This means node is currently in 'non-complaint' state, & respective deviation is getting generated)

** The service resource is not able to find the status of the 'currently sunning service', and showing the above failure message?**


Chef Version

Chef-client: 12.12.13


Platform Version

Red Hat Enterprise Linux Server release 7.5 (Maipo)


Replication Case

replicate your problem by executing below resource

service 'crond' do
provider ::Chef::Provider::Service::Systemd if RHEL_7_OR_HIGHER
action [:start, :enable]
end


Client Output

Service status on the system:
[root@test1234]# systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-05-15 11:59:24 IST; 23h ago
Main PID: 29870 (crond)
CGroup: /system.slice/crond.service
└─29870 /usr/sbin/crond -n

May 15 11:59:24 test123 systemd[1]: Started Command Scheduler.
May 15 11:59:24 test123 systemd[1]: Starting Command Scheduler...
May 15 11:59:24 test123 crond[29870]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 55% if used.)
May 15 11:59:24 test123 crond[29870]: (root) BAD FILE MODE (/etc/cron.d/0hourly)
May 15 11:59:24 test123 crond[29870]: (CRON) INFO (running with inotify support)
May 15 11:59:24 test123 crond[29870]: (CRON) INFO (@reboot jobs will be run at computer's startup.)

  • In Why-run mode: getting the below deviation

    • service[crond] action start[2019-05-13T11:19:31+05:30] INFO: Processing service[crond] action start

      • Service status not available. Assuming a prior action would have installed the service.
      • Assuming status of not running.
        (up to date)
    • service[crond] action enable[2019-05-13T11:19:31+05:30] INFO: Processing service[crond] action enable

      • Service status not available. Assuming a prior action would have installed the service.
      • Assuming status of not running.
        (up to date)

Even if the service status is active (running) i.e. '(up to date)'. Why we getting the below 2 warning/deviation messages, what is the purpose of adding it into the why-run only.
* Service status not available. Assuming a prior action would have installed the service.
* Assuming status of not running.


Stacktrace

We are refering the below files, debugged the below files stacktrace output, got below mentioned logs by debugging below files:

/chef-12.12.13/lib/chef/provider/service/simple.rb ( We are getting the message from this file in method ‘shared_resource_requirements’ in why-run mode, not getting the purpose of adding this message )

/chef-12.12.13/lib/chef/provider/service.rb
/chef-12.12.13/lib/chef/resource/service.rb
/chef-12.12.13/lib/chef/provider/service/systemd.rb


I added some print statements in above file for debugging, Logs are as below


  • yum_package[cronie] action install"CMD status :--- pid 16047 exit 0"
    "define_resource_requirements is getting calling from /chef/provider.rb"
    (up to date)

  • service[crond] action start""
    "in /chef/provider/service/systemd.rb-- systemd current resource: "
    "is_active method in /chef/provider/service/systemd.rb"
    "options: {}"
    "args: --system"
    "/usr/bin/systemctl --system is-active crond --quiet"
    "CMD status :--- pid 16052 exit 0"
    "getting current resource status in /chef/provider/service/systemd.rb"
    true
    "CMD status :--- pid 16055 exit 0"
    "CMD status :--- pid 16058 exit 0"
    "here in load_current_resource in /chef/provider/service/systemd.rb"
    <service[crond] @name: "crond" @noop: nil @before: nil @params: {} @Provider: nil @allowed_actions: [:nothing, :enable, :disable, :start, :stop, :restart, :reload, :mask, :unmask] @action: [:nothing] @Updated: false @updated_by_last_action: false @supports: {:restart=>nil, :reload=>nil, :status=>nil} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: nil @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0 @sensitive: false @service_name: "crond" @enabled: true @running: true @Masked: false @parameters: nil @pattern: "crond" @start_command: nil @stop_command: nil @status_command: nil @restart_command: nil @reload_command: nil @init_command: nil @priority: nil @timeout: nil @run_levels: nil @user: nil>
    "define_resource_requirements is getting calling from /chef/provider.rb"
    "-----------------in shared resource requirements /chef/provider/service.rb-------------"
    "--------"
    "I am printing the message from in /chef/provider/service/simple.rb"
    " define_resource_requirements in /chef/provider/service/systemd.rb :----- #Chef::Mixin::WhyRun::ResourceRequirements:0x00564f43ac1438"
    "--#Chef::Mixin::WhyRun::ResourceRequirements::Assertion:0x00564f43aab7a0--status_check_success in /chef/provider/service/systemd.rb-----------------------true-----------------"
    "Status command in /chef/provider/service/systemd.rb: "
    nil
    "Failed to determine status of service[crond], using command ."

    • Service status not available. Assuming a prior action would have installed the service.
    • Assuming status of not running."______ in action_start /chef/provider/service.rb _________"
      "load_new_resource_state: "
      "--- in new resource state --- \n before"
      nil
      "after"
      true

    (up to date)

  • service[crond] action enable""
    "in /chef/provider/service/systemd.rb-- systemd current resource: "
    "is_active method in /chef/provider/service/systemd.rb"
    "options: {}"
    "args: --system"
    "/usr/bin/systemctl --system is-active crond --quiet"
    "CMD status :--- pid 16061 exit 0"
    "getting current resource status in /chef/provider/service/systemd.rb"
    true
    "CMD status :--- pid 16064 exit 0"
    "CMD status :--- pid 16067 exit 0"
    "here in load_current_resource in /chef/provider/service/systemd.rb"
    <service[crond] @name: "crond" @noop: nil @before: nil @params: {} @Provider: nil @allowed_actions: [:nothing, :enable, :disable, :start, :stop, :restart, :reload, :mask, :unmask] @action: [:nothing] @Updated: false @updated_by_last_action: false @supports: {:restart=>nil, :reload=>nil, :status=>nil} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: nil @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0 @sensitive: false @service_name: "crond" @enabled: true @running: true @Masked: false @parameters: nil @pattern: "crond" @start_command: nil @stop_command: nil @status_command: nil @restart_command: nil @reload_command: nil @init_command: nil @priority: nil @timeout: nil @run_levels: nil @user: nil>
    "define_resource_requirements is getting calling from /chef/provider.rb"
    "-----------------in shared resource requirements /chef/provider/service.rb-------------"
    "--------"
    "I am printing the message from in /chef/provider/service/simple.rb"
    " define_resource_requirements in /chef/provider/service/systemd.rb :----- #Chef::Mixin::WhyRun::ResourceRequirements:0x00564f3ef12730"
    "--#Chef::Mixin::WhyRun::ResourceRequirements::Assertion:0x00564f3ef1c0a0--status_check_success in /chef/provider/service/systemd.rb-----------------------true-----------------"
    "Status command in /chef/provider/service/systemd.rb: "
    nil
    "Failed to determine status of service[crond], using command ."

    • Service status not available. Assuming a prior action would have installed the service.
    • Assuming status of not running."______ in action_enable /chef/provider/service.rb _________"
      "load_new_resource_state: "
      "--- in new resource state --- \n before"
      true
      "after"
      true

    (up to date)


@Vasusanghave Vasusanghave changed the title Service resource is not working as expected in why-run( while service is running showing the messages along with up-to-date status) Service resource is not working as expected not able to detect service status in why-run May 17, 2019

@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2019

this line should be entirely unnecessary and may be the cause of some of the problem:

 provider ::Chef::Provider::Service::Systemd if RHEL_7_OR_HIGHER

chef should be able to figure that out on its own. and generally injecting the provider argument and bypassing the provider resolver is going to cause bugs.

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.