Unverified Commit bdb1e57c authored by Caleb St. John's avatar Caleb St. John Committed by GitHub
Browse files

NAS-112790 / 12.0 / dont start nfs always when bindip is set (#7760)

* dont start nfs always when bindip is set

* be smarter about logging when service is stopped

* all() to any()
No related merge requests found
Showing with 15 additions and 19 deletions
+15 -19
......@@ -10,7 +10,6 @@ from middlewared.async_validators import check_path_resides_within_volume
from middlewared.validators import Range
from middlewared.service import private, SharingService, SystemServiceService, ValidationError, ValidationErrors
import middlewared.sqlalchemy as sa
from middlewared.utils import osc
from middlewared.utils.asyncio_ import asyncio_map
from middlewared.utils.path import is_child
......@@ -72,9 +71,6 @@ class NFSService(SystemServiceService):
@private
async def bindip(self, config):
bindip = [addr for addr in config['bindip'] if addr not in ['0.0.0.0', '::']]
if osc.IS_LINUX:
bindip = bindip[:1]
if bindip:
found = False
for iface in await self.middleware.call('interface.query'):
......@@ -180,9 +176,6 @@ class NFSService(SystemServiceService):
"domain"
)
if osc.IS_LINUX:
if len(new['bindip']) > 1:
verrors.add('nfs_update.bindip', 'Listening on more than one address is not supported')
bindip_choices = await self.bindip_choices()
for i, bindip in enumerate(new['bindip']):
if bindip not in bindip_choices:
......@@ -427,10 +420,6 @@ class SharingNFSService(SharingService):
@private
def validate_paths(self, data, schema_name, verrors):
if osc.IS_LINUX:
# Ganesha does not have such a restriction, each path is a different share
return
dev = None
for i, path in enumerate(data["paths"]):
if " " in path:
......@@ -554,9 +543,12 @@ class SharingNFSService(SharingService):
async def interface_post_sync(middleware):
if osc.IS_FREEBSD:
if not await middleware.call('cache.has_key', 'interfaces_are_set_up'):
await middleware.call('cache.put', 'interfaces_are_set_up', True)
if not await middleware.call('cache.has_key', 'interfaces_are_set_up'):
await middleware.call('cache.put', 'interfaces_are_set_up', True)
filters = [['srv_service', '=', 'nfs']]
options = {'get': True}
nfs = await middleware.call('datastore.query', 'services_services', filters, options)
if nfs['srv_enable'] and any([i['enabled'] for i in await middleware.call('sharing.nfs.query')]):
if (await middleware.call('nfs.config'))['bindip']:
asyncio.ensure_future(middleware.call('service.restart', 'nfs'))
......
......@@ -129,8 +129,12 @@ class FreeBSDStartNotify(threading.Thread):
async def freebsd_service(rc, verb):
result = await run("service", rc, verb, check=False, encoding="utf-8", stderr=subprocess.STDOUT)
if not verb.endswith("status") and result.returncode != 0:
logger.warning("%s %s failed with code %d: %r", rc, verb, result.returncode, result.stdout)
return result
r = await run("service", rc, verb, check=False, encoding="utf-8", stderr=subprocess.STDOUT)
if verb == 'forcestop' and r.returncode != 0 and f'{rc} not running?' not in r.stdout.decode().strip():
# we only need to log a warning if we forcestop a service and it was actually running and
# failed to stop....
logger.warning("Failed to forcestop %s with code %d with error %r", rc, r.returncode, r.stdout)
elif not verb.endswith("status") and r.returncode != 0:
logger.warning("%s %s failed with code %d: %r", rc, verb, r.returncode, r.stdout)
return r
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment