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

NAS-131083 / 25.04 / service.stop return values are swapped #14463

Merged
merged 6 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/middlewared/middlewared/plugins/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async def do_update(self, app, audit_callback, id_or_name, data):
),
roles=['SERVICE_WRITE', 'SHARING_NFS_WRITE', 'SHARING_SMB_WRITE', 'SHARING_ISCSI_WRITE', 'SHARING_FTP_WRITE']
)
@returns(Bool('started_service'))
@returns(Bool('started_service', description='Will return `true` if service successfully started'))
@pass_app(rest=True)
async def start(self, app, service, options):
"""
Expand Down Expand Up @@ -269,11 +269,13 @@ async def stop(self, app, service, options):
if service_object.deprecated:
await self.middleware.call('alert.oneshot_delete', 'DeprecatedService', service_object.name)

return False
return True
else:
self.logger.error("Service %r running after stop", service)
await self.middleware.call('service.notify_running', service)
return True
if options['silent']:
return False
raise CallError(await service_object.failure_logs() or 'Service still running after stop')

@accepts(
Str('service'),
Expand Down
5 changes: 2 additions & 3 deletions tests/api2/test_426_smb_vss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pytest_dependency import depends
from protocols import SMB
from samba import ntstatus
from middlewared.test.integration.utils import call
from middlewared.test.integration.utils.client import truenas_server


Expand Down Expand Up @@ -343,9 +344,7 @@ def test_051_disable_smb1(request):

def test_052_stopping_smb_service(request):
depends(request, ["VSS_SMB_SERVICE_STARTED"])
payload = {"service": "cifs"}
results = POST("/service/stop/", payload)
assert results.status_code == 200, results.text
assert call("service.stop", "cifs")
sleep(1)


Expand Down
2 changes: 1 addition & 1 deletion tests/api2/test_440_snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def test_SNMPv3_user_retained_across_service_restart(self):
reset_systemd_svcs("snmpd snmp-agent")

res = call('service.stop', 'snmp')
assert res is False
assert res is True
res = call('service.start', 'snmp')
assert res is True
res = call('snmp.get_snmp_users')
Expand Down
2 changes: 1 addition & 1 deletion tests/api2/test_pool_dataset_unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ def test_pool_dataset_unlock_smb(smb_user, toggle_attachments):

assert e.value.args[0] == ntstatus.NT_STATUS_BAD_NETWORK_NAME

assert call('service.stop', 'cifs') is False # successfully stopped
assert call('service.stop', 'cifs')
Loading