Skip to content

Commit

Permalink
Adapt net interface delete to 'rockstor' service null config default #…
Browse files Browse the repository at this point in the history
…2819

Block non-rocknet interface deletions for the default/no management/Web-UI
interface configuration. Raising a user visible exception explaining
the interface delete rejection, and advising the need to configure the
'rockstor' service first. This way, for default/no 'rockstor'/Web-UI service
configurations (no management interface defined) we avoid inadvertent
Web-UI outage. Once a non default 'rockstor' service/Web-UI Network
interface is established, only that interface will be bared from delete.

Fixes Web-UI silent but logged failure to properly process/fence an interface
delete request with default 'rockstor'/Web-UI configuration.
  • Loading branch information
phillxnet committed Mar 27, 2024
1 parent 792d5b7 commit 5e66d4d
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/rockstor/storageadmin/views/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,21 +554,32 @@ def delete(self, request, id):
dnet_disconnect(c, brco.docker_name)
dnet_remove(network=brco.docker_name)
else:
restricted = False
restricted: bool = False
unknown_restricted: bool = False
try:
so = Service.objects.get(name="rockstor")
config = json.loads(so.config)
if config["network_interface"] == nco.name:
restricted = True
if so.config is None:
unknown_restricted = True
else:
config = json.loads(so.config)
if config["network_interface"] == nco.name:
restricted = True
except Exception as e:
logger.exception(e)
if restricted:
e_msg = (
"This connection ({}) is designated for "
"management and cannot be deleted. If you really "
f"This connection ({nco.name}) is designated for "
"management/Web-UI and cannot be deleted. If you really "
"need to delete it, change the Rockstor service "
"configuration and try again."
).format(nco.name)
)
handle_exception(Exception(e_msg), request)
if unknown_restricted:
e_msg = (
"No connection is yet designated for management/Web-UI. "
"To avoid inadvertently deleting the Web-UI network connection, "
"first configure the Rockstor service's 'Network Interface'."
)
handle_exception(Exception(e_msg), request)
self._delete_connection(nco)
return Response()
Expand Down

0 comments on commit 5e66d4d

Please sign in to comment.