Skip to content

Commit

Permalink
[NetApp] Consider last transfer size and error for replica state
Browse files Browse the repository at this point in the history
In order to determine replica state from snapmirror, in addition to
existing check of last-transfer-end-timestamp', also add new checks
of `last-transfer-size` and `last-transfer-error`. New config option
`netapp_snapmirror_last_transfer_size_limit` added with default value
of 1MB. The last-transfer-size above this value or presence of any
last-transfer-error is considered as replica is out_of_sync.

Closes-bug: #1989175
  • Loading branch information
kpawar-sap committed Sep 28, 2022
1 parent 251cc83 commit 77e7820
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ def get_snapmirrors(self, source_share_obj, dest_share_obj):
'mirror-state',
'source-vserver',
'source-volume',
'last-transfer-end-timestamp'])
'last-transfer-end-timestamp',
'last-transfer-size',
'last-transfer-error'])
return snapmirrors

def create_snapmirror(self, source_share_obj, dest_share_obj,
Expand Down
17 changes: 16 additions & 1 deletion manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ def _get_logical_space_options(self, vserver_client, share_name):
src_volume.get('is-space-reporting-logical')
}


def _get_efficiency_options(self, vserver_client, share_name):
status = vserver_client.get_volume_efficiency_status(share_name)
cross_dedup_disabled = (status.get('policy') == 'inline-only'
Expand Down Expand Up @@ -2956,6 +2955,22 @@ def update_replica_state(self, context, replica_list, replica,
.isoformat(), 3600))):
return constants.REPLICA_STATE_OUT_OF_SYNC

replica_backend = share_utils.extract_host(replica['host'],
level='backend_name')
config = data_motion.get_backend_configuration(replica_backend)
config_size = (int(config.safe_get(
'netapp_snapmirror_last_transfer_size_limit')) * units.Ki)
last_transfer_size = int(snapmirror.get('last-transfer-size', 0))
if last_transfer_size > config_size:
return constants.REPLICA_STATE_OUT_OF_SYNC

last_transfer_error = snapmirror.get('last-transfer-error', None)
if last_transfer_error:
LOG.debug('Found last-transfer-error: %(error)s for replica: '
'%(replica)s.', {'replica': replica['id'],
'error': last_transfer_error})
return constants.REPLICA_STATE_OUT_OF_SYNC

# Check all snapshots exist
snapshots = [snap['share_replica_snapshot']
for snap in share_snapshots]
Expand Down
6 changes: 6 additions & 0 deletions manila/share/drivers/netapp/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@
default=3600, # One Hour
help='The maximum time in seconds to wait for a snapmirror '
'release when breaking snapmirror relationships.'),
cfg.IntOpt('netapp_snapmirror_last_transfer_size_limit',
min=512,
default=1024, # One MB
help='This option set the last transfer size limit (in KB) '
'of snapmirror to decide whether replica is in sync or '
'out of sync.'),
cfg.IntOpt('netapp_volume_move_cutover_timeout',
min=0,
default=3600, # One Hour,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,9 @@ def test_get_snapmirrors(self):
'mirror-state',
'source-vserver',
'source-volume',
'last-transfer-end-timestamp']
'last-transfer-end-timestamp',
'last-transfer-size',
'last-transfer-error']
)
self.assertEqual(1, self.mock_dest_client.get_snapmirrors.call_count)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4371,6 +4371,9 @@ def test_update_replica_state_in_sync(self):
self.mock_object(self.library,
'_is_readable_replica',
mock.Mock(return_value=False))
mock_backend_config = fake.get_config_cmode()
self.mock_object(data_motion, 'get_backend_configuration',
mock.Mock(return_value=mock_backend_config))

result = self.library.update_replica_state(None, [fake.SHARE],
fake.SHARE, None, [],
Expand Down Expand Up @@ -4414,6 +4417,9 @@ def test_update_replica_state_in_sync_with_snapshots(self):
self.mock_object(self.library,
'_is_readable_replica',
mock.Mock(return_value=False))
mock_backend_config = fake.get_config_cmode()
self.mock_object(data_motion, 'get_backend_configuration',
mock.Mock(return_value=mock_backend_config))

result = self.library.update_replica_state(None, [fake.SHARE],
fake.SHARE, None, snapshots,
Expand Down Expand Up @@ -4442,6 +4448,9 @@ def test_update_replica_state_missing_snapshot(self):
self.mock_object(self.library,
'_is_readable_replica',
mock.Mock(return_value=False))
mock_backend_config = fake.get_config_cmode()
self.mock_object(data_motion, 'get_backend_configuration',
mock.Mock(return_value=mock_backend_config))

result = self.library.update_replica_state(None, [fake.SHARE],
fake.SHARE, None, snapshots,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
features:
- |
NetApp driver now considers ``last-transfer-size`` and
``last-transfer-error`` fields of the snapmirror in addition to existing
``last-transfer-end-timestamp`` to decide whether replica is in_sync or
out_of_sync. Added new config option
`netapp_snapmirror_last_transfer_size_limit` (default 1MB). If value of
`last-transfer-size` field is greater than config value or if
`last-transfer-error` field is present, then replica is out_of_sync.

0 comments on commit 77e7820

Please sign in to comment.