Hello community, here is the log from the commit of package salt-shaptools for openSUSE:Factory checked in at 2020-06-09 00:05:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/salt-shaptools (Old) and /work/SRC/openSUSE:Factory/.salt-shaptools.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "salt-shaptools" Tue Jun 9 00:05:57 2020 rev:16 rq:812471 version:0.3.8+git.1591605110.7cde32d Changes: -------- --- /work/SRC/openSUSE:Factory/salt-shaptools/salt-shaptools.changes 2020-06-04 20:57:40.383263663 +0200 +++ /work/SRC/openSUSE:Factory/.salt-shaptools.new.3606/salt-shaptools.changes 2020-06-09 00:08:00.942004070 +0200 @@ -1,0 +2,6 @@ +Fri Jun 5 07:46:01 UTC 2020 - nick wang <[email protected]> + +- Version 0.3.8 + * DRBD: Avoid CommandExecutionError when estimation sync time not ready + +------------------------------------------------------------------- Old: ---- salt-shaptools-0.3.7+git.1591284143.9989ae7.tar.gz New: ---- salt-shaptools-0.3.8+git.1591605110.7cde32d.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ salt-shaptools.spec ++++++ --- /var/tmp/diff_new_pack.TetCpe/_old 2020-06-09 00:08:02.090008143 +0200 +++ /var/tmp/diff_new_pack.TetCpe/_new 2020-06-09 00:08:02.094008157 +0200 @@ -1,7 +1,7 @@ # # spec file for package salt-shaptools # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,12 +19,12 @@ # See also https://en.opensuse.org/openSUSE:Specfile_guidelines Name: salt-shaptools -Version: 0.3.7+git.1591284143.9989ae7 +Version: 0.3.8+git.1591605110.7cde32d Release: 0 Summary: Salt modules and states for SAP Applications and SLE-HA components management License: Apache-2.0 -Url: https://github.com/SUSE/%{name} +URL: https://github.com/SUSE/%{name} Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch ++++++ _service ++++++ --- /var/tmp/diff_new_pack.TetCpe/_old 2020-06-09 00:08:02.122008256 +0200 +++ /var/tmp/diff_new_pack.TetCpe/_new 2020-06-09 00:08:02.122008256 +0200 @@ -4,8 +4,8 @@ <param name="scm">git</param> <param name="exclude">.git</param> <param name="filename">salt-shaptools</param> - <param name="versionformat">0.3.7+git.%ct.%h</param> - <param name="revision">9989ae7bec9c54c17db26aeac3a9f75aac47e27e</param> + <param name="versionformat">0.3.8+git.%ct.%h</param> + <param name="revision">7cde32d3f868d62dd1f65c9cde41f6929e8362c4</param> </service> <service name="recompress" mode="disabled"> ++++++ salt-shaptools-0.3.7+git.1591284143.9989ae7.tar.gz -> salt-shaptools-0.3.8+git.1591605110.7cde32d.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.7+git.1591284143.9989ae7/_service new/salt-shaptools-0.3.8+git.1591605110.7cde32d/_service --- old/salt-shaptools-0.3.7+git.1591284143.9989ae7/_service 2020-06-04 17:22:23.000000000 +0200 +++ new/salt-shaptools-0.3.8+git.1591605110.7cde32d/_service 2020-06-08 10:31:50.000000000 +0200 @@ -4,7 +4,7 @@ <param name="scm">git</param> <param name="exclude">.git</param> <param name="filename">salt-shaptools</param> - <param name="versionformat">0.3.7+git.%ct.%h</param> + <param name="versionformat">0.3.8+git.%ct.%h</param> <param name="revision">%%VERSION%%</param> </service> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.7+git.1591284143.9989ae7/salt/modules/drbdmod.py new/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt/modules/drbdmod.py --- old/salt-shaptools-0.3.7+git.1591284143.9989ae7/salt/modules/drbdmod.py 2020-06-04 17:22:23.000000000 +0200 +++ new/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt/modules/drbdmod.py 2020-06-08 10:31:50.000000000 +0200 @@ -280,6 +280,37 @@ return True +def _get_json_output_save(command): + ''' + A warpper of get json command to acommandate json output issues + ''' + + error_str = '"estimated-seconds-to-finish": nan,' + replace_str = '"estimated-seconds-to-finish": 987654321,' + results = __salt__['cmd.run_all'](command) + + if 'retcode' not in results or results['retcode'] != 0: + LOGGER.info("Error running command \"%s\". Error message: %s (%s)", + command, results['stderr'], results['retcode']) + return None + + # https://github.com/LINBIT/drbd-utils/commit/104293030b2c0106b4791edb3eec38b476652a2e + # results['stdout'] is unicode + s_result = str(results['stdout']) + if error_str in s_result: + s_result = s_result.replace(error_str, replace_str) + results['stdout'] = six.text_type(s_result) + + try: + ret = salt.utils.json.loads(results['stdout'], strict=False) + + except ValueError: + raise CommandExecutionError('Error trying to load the json output', + info=results) + + return ret + + def overview(): ''' Show status of the DRBD devices, support two nodes only. @@ -597,18 +628,7 @@ # Only support json format cmd = 'drbdsetup show --json {}'.format(name) - results = __salt__['cmd.run_all'](cmd) - - if 'retcode' not in results or results['retcode'] != 0: - ret['comment'] = 'Error({}) happend when show resource via drbdsetup.'.format( - results['retcode']) - return ret - - try: - ret = salt.utils.json.loads(results['stdout'], strict=False) - except ValueError: - raise CommandExecutionError('Error happens when try to load the json output.', - info=results) + ret = _get_json_output_save(cmd) return ret @@ -635,17 +655,7 @@ cmd = 'drbdsetup status --json {}'.format(name) - results = __salt__['cmd.run_all'](cmd) - - if 'retcode' not in results or results['retcode'] != 0: - LOGGER.info('No drbdsetup status due to %s (%s).', results['stderr'], results['retcode']) - return None - - try: - ret = salt.utils.json.loads(results['stdout'], strict=False) - except ValueError: - raise CommandExecutionError('Error happens when try to load the json output.', - info=results) + ret = _get_json_output_save(cmd) return ret diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.7+git.1591284143.9989ae7/salt-shaptools.changes new/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt-shaptools.changes --- old/salt-shaptools-0.3.7+git.1591284143.9989ae7/salt-shaptools.changes 2020-06-04 17:22:23.000000000 +0200 +++ new/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt-shaptools.changes 2020-06-08 10:31:50.000000000 +0200 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Jun 5 07:46:01 UTC 2020 - nick wang <[email protected]> + +- Version 0.3.8 + * DRBD: Avoid CommandExecutionError when estimation sync time not ready + +------------------------------------------------------------------- Thu Jun 4 09:17:52 UTC 2020 - Xabier Arbulu <[email protected]> - Version 0.3.7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.7+git.1591284143.9989ae7/salt-shaptools.spec new/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt-shaptools.spec --- old/salt-shaptools-0.3.7+git.1591284143.9989ae7/salt-shaptools.spec 2020-06-04 17:22:23.000000000 +0200 +++ new/salt-shaptools-0.3.8+git.1591605110.7cde32d/salt-shaptools.spec 2020-06-08 10:31:50.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package salt-shaptools # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ Summary: Salt modules and states for SAP Applications and SLE-HA components management License: Apache-2.0 -Url: https://github.com/SUSE/%{name} +URL: https://github.com/SUSE/%{name} Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.3.7+git.1591284143.9989ae7/tests/unit/modules/test_drbdmod.py new/salt-shaptools-0.3.8+git.1591605110.7cde32d/tests/unit/modules/test_drbdmod.py --- old/salt-shaptools-0.3.7+git.1591284143.9989ae7/tests/unit/modules/test_drbdmod.py 2020-06-04 17:22:23.000000000 +0200 +++ new/salt-shaptools-0.3.8+git.1591605110.7cde32d/tests/unit/modules/test_drbdmod.py 2020-06-08 10:31:50.000000000 +0200 @@ -355,16 +355,12 @@ mock_cmd.assert_called_once_with('drbdsetup show --json all') # Test 2: Return code is not 0 - ret = {'name': 'all', - 'result': False, - 'comment': 'Error(10) happend when show resource via drbdsetup.'} - - fake = {'retcode': 10} + fake = {'stderr': '', 'retcode': 10} mock_cmd = MagicMock(return_value=fake) with patch.dict(drbd.__salt__, {'cmd.run_all': mock_cmd}): - assert drbd.setup_show() == ret + assert not drbd.setup_show() mock_cmd.assert_called_once_with('drbdsetup show --json all') # Test 3: Raise json ValueError @@ -507,7 +503,8 @@ mock_cmd = MagicMock(return_value=fake) with patch.dict(drbd.__salt__, {'cmd.run_all': mock_cmd}): - self.assertRaises(exceptions.CommandExecutionError, drbd.setup_status) + self.assertRaises(exceptions.CommandExecutionError, + drbd.setup_status) def test_check_sync_status(self): ''' @@ -820,3 +817,83 @@ 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') + + # Test 4: Test json return "estimated-seconds-to-finish": nan, + # https://github.com/SUSE/salt-shaptools/pull/65 + fake = {} + fake['stdout'] = ''' +[ +{ + "name": "shanghai", + "node-id": 1, + "role": "Primary", + "suspended": false, + "write-ordering": "flush", + "devices": [ + { + "volume": 0, + "minor": 2, + "disk-state": "UpToDate", + "client": false, + "quorum": true, + "size": 409600, + "read": 0, + "written": 0, + "al-writes": 0, + "bm-writes": 0, + "upper-pending": 0, + "lower-pending": 3 + } ], + "connections": [ + { + "peer-node-id": 2, + "name": "SLE12-sp4-node2", + "connection-state": "Connected", + "congested": false, + "peer-role": "Secondary", + "ap-in-flight": 0, + "rs-in-flight": 0, + "peer_devices": [ + { + "volume": 0, + "replication-state": "SyncSource", + "peer-disk-state": "Inconsistent", + "peer-client": false, + "resync-suspended": "no", + "received": 0, + "sent": 0, + "out-of-sync": 409600, + "pending": 0, + "unacked": 0, + "has-sync-details": true, + "has-online-verify-details": false, + "percent-in-sync": 0.00, + "rs-total": 819200, + "rs-dt-start-ms": 0, + "rs-paused-ms": 0, + "rs-dt0-ms": 0, + "rs-db0-sectors": 0, + "rs-dt1-ms": 0, + "rs-db1-sectors": 0, + "rs-failed": 0, + "rs-same-csum": 0, + "want": 0.00, + "db0/dt0 [MiB/s]": 0.00, + "db1/dt1 [MiB/s]": 0.00, + "estimated-seconds-to-finish": nan, + "db/dt [MiB/s]": 0.00, + "percent-resync-done": 0.00 + } ] + } ] +} +] + +''' + 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')
