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.running: failure to start with enable: True reports no changes / no errors #5894

Closed
mgwilliams opened this issue Jul 2, 2013 · 13 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior help-wanted Community help is needed to resolve this severity-low 4th level, cosemtic problems, work around exists
Milestone

Comments

@mgwilliams
Copy link
Contributor

I believe there is a bug in service.running.

If a service fails to start, but enable: is provided, it returns only the status of service._enable and fails to return the failure to start.

@terminalmage
Copy link
Contributor

Thanks, I'll try to reproduce. What distro/version are you running? We have multiple service backends, so it might be an issue with the backend rather than the state itself.

@ghost ghost assigned terminalmage Jul 2, 2013
@terminalmage
Copy link
Contributor

Actually, this doesn't look like a bug at all. Did you actually experience this problem, or is this report just from looking at the code? If you look at line 295 in this block, the False result is indeed returned.

    changes = {name: __salt__['service.start'](name)}

    if not changes[name]:
        ret['result'] = False
        ret['comment'] = 'Service {0} failed to start'.format(name)
        if enable is True:
            ret = _enable(name, False, **kwargs)
            ret['result'] = False
        elif enable is False:
            return _disable(name, False, **kwargs)
        else:
            return ret

@terminalmage
Copy link
Contributor

If anything, it looks like there might be an issue with the return data if enable is False.

@mgwilliams
Copy link
Contributor Author

I did experience it. If I'm reading correctly, if the service fails to start and enable is True, it doesn't actually return in this block. Instead, it flows on to here:

    if enable is True:
        return _enable(name, True, **kwargs)

@terminalmage
Copy link
Contributor

If the service fails to start, then changes[name] will be False, as shown in my example above.

@terminalmage
Copy link
Contributor

Ahh I see what is going on here. There is no return after the result is set to False.

@mgwilliams
Copy link
Contributor Author

Yes, so it continues on and runs _enable a second time, and returns the result of that.

@terminalmage
Copy link
Contributor

The _enable and _disable functions need to be smarter about how they set the result value. I'll audit them and make sure they're returning the proper info, this should take care of the issue. Thanks for the report.

@basepi
Copy link
Contributor

basepi commented Jul 17, 2013

@mgwilliams Did your pull request resolve this issue? Can it be closed?

@mgwilliams
Copy link
Contributor Author

@basepi Yes, it did. Thanks!

@ruimarinho
Copy link

Using latest git code (0.17.x), I'm having a somewhat similar issue - a failure to start a service is not correctly reported back to the master as such.

Here's the output from a manual call on the minion shell:

/etc/init.d/clamav-daemon start
[FAIL] Clamav signatures not found in /var/lib/clamav ... failed!
[FAIL] Please retrieve them using freshclam ... failed!
[FAIL] Then run '/etc/init.d/clamav-daemon start' ... failed!

And the output on the master:

State: - service
Name:      clamav-daemon
Function:  running
    Result:    True
    Comment:   Service clamav-daemon is already enabled, and is running
    Changes:

The state is basic:

clamav-daemon:
  pkg:
    - installed
  service:
    - running
    - enable: True
    - require:
      - pkg: clamav-daemon

I'm on Debian 7 (Wheezy).

@basepi
Copy link
Contributor

basepi commented Oct 21, 2013

@ruimarinho Could you create a new issue? I'm guessing it's a slightly different bug.

@ruimarinho
Copy link

Of course, will do. Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior help-wanted Community help is needed to resolve this severity-low 4th level, cosemtic problems, work around exists
Projects
None yet
Development

No branches or pull requests

4 participants