Skip to content

Do not fail service.dead/service.disabled for services that are not present - #70654

Open
LakshmikanthRaju wants to merge 1 commit into
saltstack:3008.xfrom
LakshmikanthRaju:fix/70396-service-dead-disabled-missing-service/3008.x
Open

LakshmikanthRaju wants to merge 1 commit into
saltstack:3008.xfrom
LakshmikanthRaju:fix/70396-service-dead-disabled-missing-service/3008.x

Conversation

@LakshmikanthRaju

@LakshmikanthRaju LakshmikanthRaju commented Nov 3, 2026 •

Copy link
Copy Markdown

What does this PR do?

Do not fail service.dead/service.disabled for services that are not present

A service that is not present is by definition neither running nor enabled, so these states should pass.

  • service.dead now passes in test mode too, matching service.disabled
  • treat a unit lookup error ("Failed to get information on unit") as "not present" in service.dead and service.disabled; offline mode and daemon-reload errors still fail
  • systemd_service._check_available returns False on exit status 4 when the systemd version is unknown and the output cannot be parsed

What issues does this PR fix or reference?

Fixes #70396

Previous Behavior

When specifying state service.dead/service.disabled with a service that is not present on the system, the state will fail.

New Behavior

Do not fail service.dead/service.disabled for services that are not present

Testing

Upgrade salt and ran the below commands to test the fix

[worker@lvn-dvm-10-161-243-165 salt-service-missing-fix]$ sudo salt-call --local state.single service.disabled nosuchsvc
local:
----------
          ID: nosuchsvc
    Function: service.disabled
      Result: True
     Comment: The named service nosuchsvc is not available
     Started: 06:57:33.300536
    Duration: 44.874 ms
     Changes:   

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:  44.874 ms
[worker@lvn-dvm-10-161-243-165 salt-service-missing-fix]$ sudo salt-call --local state.single service.dead nosuchsvc
local:
----------
          ID: nosuchsvc
    Function: service.dead
      Result: True
     Comment: The named service nosuchsvc is not available
     Started: 06:57:51.810232
    Duration: 36.923 ms
     Changes:   

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:  36.923 ms
[worker@lvn-dvm-10-161-243-165 salt-service-missing-fix]$ sudo salt-call --local state.single service.dead nosuchsvc test=True
local:
----------
          ID: nosuchsvc
    Function: service.dead
      Result: True
     Comment: The named service nosuchsvc is not available
     Started: 06:58:25.991916
    Duration: 39.134 ms
     Changes:   

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:  39.134 ms
[worker@lvn-dvm-10-161-243-165 salt-service-missing-fix]$ sudo salt-call --local state.single service.enabled nosuchsvc
[ERROR   ] The named service nosuchsvc is not available
local:
----------
          ID: nosuchsvc
    Function: service.enabled
      Result: False
     Comment: The named service nosuchsvc is not available
     Started: 06:58:40.325711
    Duration: 38.457 ms
     Changes:   

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:  38.457 ms

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes/No

Comment thread salt/states/service.py Resolved
@LakshmikanthRaju
LakshmikanthRaju changed the base branch from master to 3008.x November 4, 2026 04:36
@LakshmikanthRaju
LakshmikanthRaju force-pushed the fix/70396-service-dead-disabled-missing-service/3008.x branch from 75a79b5 to c9251aa Compare November 5, 2026 04:37
…resent

A service that is not present is by definition neither running nor
enabled, so these states should pass.

- add salt.exceptions.ServiceNotFoundError (a CommandExecutionError)
- systemd_service and mac_service raise it when the service does not
  exist; service.dead and service.disabled treat it as "not present".
  Other errors (offline mode, daemon-reload failure) still fail
- service.dead now passes in test mode too, matching service.disabled
- systemd_service._check_available returns False on exit status 4 when
  the systemd version is unknown and the output cannot be parsed

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: service.disabled/service.dead should not fail if a service is not found

2 participants