Skip to content

Commit

Permalink
When updating an iSCSI target reset live target parameters if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeagherix committed Apr 26, 2024
1 parent 42dee16 commit 5ea3c14
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/middlewared/middlewared/plugins/iscsi_/targets.py
Expand Up @@ -365,9 +365,23 @@ async def do_update(self, audit_callback, id_, data):
await self._service_change('iscsitarget', 'reload', options={'ha_propagate': False})

# Then process the BACKUP config if we are HA and ALUA is enabled.
if await self.middleware.call("iscsi.global.alua_enabled") and await self.middleware.call('failover.remote_connected'):
run_on_peer = await self.middleware.call("iscsi.global.alua_enabled") and await self.middleware.call('failover.remote_connected')
if run_on_peer:
await self.middleware.call('failover.call_remote', 'service.reload', ['iscsitarget'])

# NOTE: Any options whose keys are omitted will be removed from the config i.e. we will deliberately revert removed items
# to SCST defaults
old_options = set(old.get('options', {}).keys())
if old_options:
removed_options = old_options - set(new.get('options', {}).keys())
if removed_options:
global_basename = (await self.middleware.call('iscsi.global.config'))['basename']
iqn = f'{global_basename}:{new["name"]}'
for param in removed_options:
await self.middleware.call('iscsi.scst.reset_target_parameter', iqn, param)
if run_on_peer:
await self.middleware.call('failover.call_remote', 'iscsi.scst.reset_target_parameter', [iqn, param])

return await self.get_instance(id_)

@accepts(Int('id'),
Expand Down

0 comments on commit 5ea3c14

Please sign in to comment.