Hello community, here is the log from the commit of package salt-shaptools for openSUSE:Factory checked in at 2019-12-23 22:45:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/salt-shaptools (Old) and /work/SRC/openSUSE:Factory/.salt-shaptools.new.6675 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "salt-shaptools" Mon Dec 23 22:45:58 2019 rev:8 rq:758957 version:0.2.9 Changes: -------- --- /work/SRC/openSUSE:Factory/salt-shaptools/salt-shaptools.changes 2019-12-21 12:33:01.251410015 +0100 +++ /work/SRC/openSUSE:Factory/.salt-shaptools.new.6675/salt-shaptools.changes 2019-12-23 22:48:57.218101090 +0100 @@ -1,0 +2,13 @@ +Mon Dec 23 07:39:31 UTC 2019 - nick wang <[email protected]> + +- Version 0.2.9 + * DRBD: refactory check_sync_status to avoid call drbdsetup + multiple times + +------------------------------------------------------------------- +Fri Dec 20 09:12:51 UTC 2019 - nick wang <[email protected]> + +- Version 0.2.8 + * DRBD: check unfinished request in sync status via json + +------------------------------------------------------------------- Old: ---- salt-shaptools-0.2.7.tar.gz New: ---- salt-shaptools-0.2.9.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ salt-shaptools.spec ++++++ --- /var/tmp/diff_new_pack.MImIiV/_old 2019-12-23 22:48:57.702101268 +0100 +++ /var/tmp/diff_new_pack.MImIiV/_new 2019-12-23 22:48:57.702101268 +0100 @@ -19,7 +19,7 @@ # See also https://en.opensuse.org/openSUSE:Specfile_guidelines Name: salt-shaptools -Version: 0.2.7 +Version: 0.2.9 Release: 0 Summary: Salt modules and states for SAP Applications and SLE-HA components management ++++++ salt-shaptools-0.2.7.tar.gz -> salt-shaptools-0.2.9.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.7/salt/modules/drbdmod.py new/salt-shaptools-0.2.9/salt/modules/drbdmod.py --- old/salt-shaptools-0.2.7/salt/modules/drbdmod.py 2019-12-19 13:09:10.379511814 +0100 +++ new/salt-shaptools-0.2.9/salt/modules/drbdmod.py 2019-12-23 09:51:40.024493544 +0100 @@ -223,48 +223,29 @@ func(line) -def _is_local_all_uptodated(name): +def _is_local_all_uptodated(res, output): ''' - Check whether all local volumes are UpToDate. + Check whether all local volumes of given resource are UpToDate. ''' - if __salt__['drbd.json']: - output = OUTPUT_OPTIONS['json'] - else: - output = OUTPUT_OPTIONS['text'] - - res = output["get_res_func"](name) - if not res: - return False - - # Since name is not all, res only have one element - for vol in res[0][output["volume"]]: + for vol in res[output["volume"]]: if vol[output["state"]] != 'UpToDate': return False return True -def _is_peers_uptodated(name, peernode='all'): +def _is_peers_uptodated(res, output, peernode='all'): ''' - Check whether all volumes of peer node are UpToDate. + Check whether all volumes of peer node of given resource are UpToDate. .. note:: If peernode is not match, will return None, same as False. ''' - if __salt__['drbd.json']: - output = OUTPUT_OPTIONS['json'] - else: - output = OUTPUT_OPTIONS['text'] - - res = output["get_res_func"](name) - - if not res: - return False + ret = False - # Since name is not all, res only have one element - for node in res[0][output["connection"]]: + for node in res[output["connection"]]: if peernode != 'all' and node[output["peer_node"]] != peernode: continue @@ -278,6 +259,27 @@ return ret +def _is_no_backing_dev_request(res, output): + ''' + Check whether all volumes have no unfinished backing device request. + Only working when json status supported. + + Metadata still need to sync to disk after state changed. + Only reply to sync target to change when I/O request finished, + which is unpredictable. Local refernece count is not 0 before endio. + + ''' + if not __salt__['drbd.json']: + return True + + # Since name is not all, res only have one element + for vol in res[output["volume"]]: + if int(vol[output["local_cnt"]]) != 0: + return False + + return True + + def overview(): ''' Show status of the DRBD devices, support two nodes only. @@ -657,6 +659,7 @@ "peer_node": "name", "peer_node_vol": "peer_devices", "peer_node_state": "peer-disk-state", + "local_cnt": "lower-pending", "get_res_func": setup_status }, "text": { @@ -689,8 +692,22 @@ salt '*' drbd.check_sync_status <resource name> <peernode name> ''' - if _is_local_all_uptodated(name) and _is_peers_uptodated( - name, peernode=peernode): + if __salt__['drbd.json']: + output = OUTPUT_OPTIONS['json'] + else: + output = OUTPUT_OPTIONS['text'] + + # Need a specific node name instead of `all`. res should only have one element + resources = output["get_res_func"](name) + + if not resources: + return False + + res = resources[0] + + if _is_local_all_uptodated(res, output) and _is_peers_uptodated( + res, output, peernode=peernode) and _is_no_backing_dev_request( + res, output): return True return False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.7/salt-shaptools.changes new/salt-shaptools-0.2.9/salt-shaptools.changes --- old/salt-shaptools-0.2.7/salt-shaptools.changes 2019-12-19 13:09:10.379511814 +0100 +++ new/salt-shaptools-0.2.9/salt-shaptools.changes 2019-12-23 09:51:40.024493544 +0100 @@ -1,4 +1,17 @@ ------------------------------------------------------------------- +Mon Dec 23 07:39:31 UTC 2019 - nick wang <[email protected]> + +- Version 0.2.9 + * DRBD: refactory check_sync_status to avoid call drbdsetup + multiple times + +------------------------------------------------------------------- +Fri Dec 20 09:12:51 UTC 2019 - nick wang <[email protected]> + +- Version 0.2.8 + * DRBD: check unfinished request in sync status via json + +------------------------------------------------------------------- Mon Dec 16 09:31:18 UTC 2019 - Xabier Arbulu <[email protected]> - Version 0.2.7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.7/salt-shaptools.spec new/salt-shaptools-0.2.9/salt-shaptools.spec --- old/salt-shaptools-0.2.7/salt-shaptools.spec 2019-12-19 13:09:10.379511814 +0100 +++ new/salt-shaptools-0.2.9/salt-shaptools.spec 2019-12-23 09:51:40.024493544 +0100 @@ -19,7 +19,7 @@ # See also https://en.opensuse.org/openSUSE:Specfile_guidelines Name: salt-shaptools -Version: 0.2.7 +Version: 0.2.9 Release: 0 Summary: Salt modules and states for SAP Applications and SLE-HA components management diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.7/tests/unit/modules/test_drbdmod.py new/salt-shaptools-0.2.9/tests/unit/modules/test_drbdmod.py --- old/salt-shaptools-0.2.7/tests/unit/modules/test_drbdmod.py 2019-12-19 13:09:10.379511814 +0100 +++ new/salt-shaptools-0.2.9/tests/unit/modules/test_drbdmod.py 2019-12-23 09:51:40.024493544 +0100 @@ -623,40 +623,141 @@ 'drbd.json': False}): assert not drbd.check_sync_status('beijing') - # Test 4.2: Test status return Error + def test_check_sync_status_drbdsetup_json(self): + ''' + Test if check_sync_status function work well with drbdsetup status --json + in drbd9 and drbd-utils >= 9.0.0 + ''' + + # Test 1: Test all UpToDate fake = {} fake['stdout'] = ''' -beijing role:Primary - volume:0 disk:UpToDate - volume:1 disk:UpToDate - node2 role:Secondary - volume:0 peer-disk:UpToDate - volume:1 peer-disk:UpToDate - node3 role:Secondary - volume:0 peer-disk:UpToDate - volume:1 peer-disk:UpToDate +[ +{ + "name": "shanghai", + "node-id": 1, + "role": "Secondary", + "suspended": false, + "write-ordering": "flush", + "devices": [ + { + "volume": 0, + "minor": 2, + "disk-state": "UpToDate", + "client": false, + "quorum": true, + "size": 699332, + "read": 0, + "written": 0, + "al-writes": 0, + "bm-writes": 0, + "upper-pending": 0, + "lower-pending": 0 + } ], + "connections": [ + { + "peer-node-id": 2, + "name": "dummytest-drbd02", + "connection-state": "Connected", + "congested": false, + "peer-role": "Secondary", + "ap-in-flight": 0, + "rs-in-flight": 0, + "peer_devices": [ + { + "volume": 0, + "replication-state": "Established", + "peer-disk-state": "UpToDate", + "peer-client": false, + "resync-suspended": "no", + "received": 0, + "sent": 0, + "out-of-sync": 0, + "pending": 0, + "unacked": 0, + "has-sync-details": false, + "has-online-verify-details": false, + "percent-in-sync": 100.00 + } ] + } ] +} +] ''' fake['stderr'] = "" fake['retcode'] = 0 - fake1 = {} - fake1['stdout'] = "" - fake1['stderr'] = "" - fake1['retcode'] = 1 - mock_cmd = MagicMock(side_effect=[fake, fake1]) + mock_cmd = MagicMock(return_value=fake) - with patch.dict(drbd.__salt__, {'cmd.run_all': mock_cmd, - 'drbd.json': False}): - assert not drbd.check_sync_status('beijing') + with patch.dict(drbd.__salt__, {'cmd.run_all': mock_cmd}): + assert drbd.check_sync_status('shanghai') + mock_cmd.assert_called_with('drbdsetup status --json shanghai') - def test_check_sync_status_drbdsetup_json(self): - ''' - Test if check_sync_status function work well with drbdsetup status --json - in drbd9 and drbd-utils >= 9.0.0 - ''' + # Test 2: Test _is_no_backing_dev_request() have unfinished requrests + fake = {} + fake['stdout'] = ''' +[ +{ + "name": "shanghai", + "node-id": 1, + "role": "Secondary", + "suspended": false, + "write-ordering": "flush", + "devices": [ + { + "volume": 0, + "minor": 2, + "disk-state": "UpToDate", + "client": false, + "quorum": true, + "size": 699332, + "read": 0, + "written": 0, + "al-writes": 0, + "bm-writes": 0, + "upper-pending": 0, + "lower-pending": 3 + } ], + "connections": [ + { + "peer-node-id": 2, + "name": "dummytest-drbd02", + "connection-state": "Connected", + "congested": false, + "peer-role": "Secondary", + "ap-in-flight": 0, + "rs-in-flight": 0, + "peer_devices": [ + { + "volume": 0, + "replication-state": "Established", + "peer-disk-state": "UpToDate", + "peer-client": false, + "resync-suspended": "no", + "received": 0, + "sent": 0, + "out-of-sync": 0, + "pending": 0, + "unacked": 0, + "has-sync-details": false, + "has-online-verify-details": false, + "percent-in-sync": 100.00 + } ] + } ] +} +] - # Test 1: Test all UpToDate +''' + fake['stderr'] = "" + fake['retcode'] = 0 + + mock_cmd = MagicMock(return_value=fake) + + with patch.dict(drbd.__salt__, {'cmd.run_all': mock_cmd}): + assert not drbd.check_sync_status('shanghai') + mock_cmd.assert_called_with('drbdsetup status --json shanghai') + + # Test 3: Test _is_no_backing_dev_request() all requrests finished fake = {} fake['stdout'] = ''' [
