NebraLtd / hm-diag

Helium Miner Diagnostics
https://nebra.io/hnt
MIT License
21 stars 23 forks source link

better error message when no ECC found on I2C bus #266

Open shawaj opened 2 years ago

shawaj commented 2 years ago

When no ECC can be found on the I2C bus we get the following output:

root@dd264db:/opt# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

And diagnostics fails with the following:

2021-12-04 01:06:24,714 - [INFO] - hm_pyhelper.miner_param - (miner_param.py).run_gateway_mfr -- /opt/python-dependencies/hm_pyhelper/miner_param.py:(41) - gateway_mfr response stdout: b'{\n  "result": "fail",\n  "tests": [\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "serial"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "zone_locked(data)"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "zone_locked(config)"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "slot_config(0..=15, ecc)"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "key_config(0..=15, ecc)"\n    },\n    {\n      "output": "ecc608 error\\n\\nCaused by:\\n    timeout/retry error",\n      "result": "fail",\n      "test": "miner_key(0)"\n    },\n    {\n      "output": "ecc608 error\\n\\nCaused by:\\n    timeout/retry error",\n      "result": "fail",\n      "test": "sign(0)"\n    },\n    {\n      "output": "ecc608 error\\n\\nCaused by:\\n    timeout/retry error",\n      "result": "fail",\n      "test": "ecdh(0)"\n    }\n  ]\n}\n'
 diagnostics  INFO:hm_pyhelper.miner_param:gateway_mfr response stdout: b'{\n  "result": "fail",\n  "tests": [\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "serial"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "zone_locked(data)"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "zone_locked(config)"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "slot_config(0..=15, ecc)"\n    },\n    {\n      "output": "timeout/retry error",\n      "result": "fail",\n      "test": "key_config(0..=15, ecc)"\n    },\n    {\n      "output": "ecc608 error\\n\\nCaused by:\\n    timeout/retry error",\n      "result": "fail",\n      "test": "miner_key(0)"\n    },\n    {\n      "output": "ecc608 error\\n\\nCaused by:\\n    timeout/retry error",\n      "result": "fail",\n      "test": "sign(0)"\n    },\n    {\n      "output": "ecc608 error\\n\\nCaused by:\\n    timeout/retry error",\n      "result": "fail",\n      "test": "ecdh(0)"\n    }\n  ]\n}\n'
 diagnostics  2021-12-04 01:06:24,715 - [INFO] - hm_pyhelper.miner_param - (miner_param.py).run_gateway_mfr -- /opt/python-dependencies/hm_pyhelper/miner_param.py:(43) - gateway_mfr response stderr: b''
 diagnostics  INFO:hm_pyhelper.miner_param:gateway_mfr response stderr: b''
 diagnostics  2021-12-04 01:06:24,751 - [ERROR] - hm_pyhelper.miner_param - (miner_param.py).run_gateway_mfr -- /opt/python-dependencies/hm_pyhelper/miner_param.py:(47) - gateway_mfr exited with a non-zero status
 diagnostics  Traceback (most recent call last):
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/miner_param.py", line 36, in run_gateway_mfr
 diagnostics      run_gateway_mfr_result = subprocess.run(
 diagnostics    File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
 diagnostics      raise CalledProcessError(retcode, process.args,
 diagnostics  subprocess.CalledProcessError: Command '['/opt/python-dependencies/hm_pyhelper/gateway_mfr', 'provision']' returned non-zero exit status 1.
 diagnostics  ERROR:hm_pyhelper.miner_param:gateway_mfr exited with a non-zero status
 diagnostics  Traceback (most recent call last):
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/miner_param.py", line 36, in run_gateway_mfr
 diagnostics      run_gateway_mfr_result = subprocess.run(
 diagnostics    File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
 diagnostics      raise CalledProcessError(retcode, process.args,
 diagnostics  subprocess.CalledProcessError: Command '['/opt/python-dependencies/hm_pyhelper/gateway_mfr', 'provision']' returned non-zero exit status 1.
 diagnostics  [2021-12-04 01:06:24 +0000] [8] [ERROR] Exception in worker process
 diagnostics  Traceback (most recent call last):
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/miner_param.py", line 36, in run_gateway_mfr
 diagnostics      run_gateway_mfr_result = subprocess.run(
 diagnostics    File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
 diagnostics      raise CalledProcessError(retcode, process.args,
 diagnostics  subprocess.CalledProcessError: Command '['/opt/python-dependencies/hm_pyhelper/gateway_mfr', 'provision']' returned non-zero exit status 1.
 diagnostics  
 diagnostics  During handling of the above exception, another exception occurred:
 diagnostics  
 diagnostics  Traceback (most recent call last):
 diagnostics    File "/opt/python-dependencies/gunicorn/arbiter.py", line 589, in spawn_worker
 diagnostics      worker.init_process()
 diagnostics    File "/opt/python-dependencies/gunicorn/workers/base.py", line 134, in init_process
 diagnostics      self.load_wsgi()
 diagnostics    File "/opt/python-dependencies/gunicorn/workers/base.py", line 146, in load_wsgi
 diagnostics      self.wsgi = self.app.wsgi()
 diagnostics    File "/opt/python-dependencies/gunicorn/app/base.py", line 67, in wsgi
 diagnostics      self.callable = self.load()
 diagnostics    File "/opt/python-dependencies/gunicorn/app/wsgiapp.py", line 58, in load
 diagnostics      return self.load_wsgiapp()
 diagnostics    File "/opt/python-dependencies/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
 diagnostics      return util.import_app(self.app_uri)
 diagnostics    File "/opt/python-dependencies/gunicorn/util.py", line 359, in import_app
 diagnostics      mod = importlib.import_module(module)
 diagnostics    File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
 diagnostics      return _bootstrap._gcd_import(name[level:], package, level)
 diagnostics    File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
 diagnostics    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
 diagnostics    File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
 diagnostics    File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
 diagnostics    File "<frozen importlib._bootstrap_external>", line 883, in exec_module
 diagnostics    File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 diagnostics    File "/opt/python-dependencies/hw_diag/__init__.py", line 3, in <module>
 diagnostics      wsgi_app = get_app(__name__)
 diagnostics    File "/opt/python-dependencies/hw_diag/app.py", line 30, in get_app
 diagnostics      perform_key_provisioning()
 diagnostics    File "/opt/python-dependencies/decorator.py", line 232, in fun
 diagnostics      return caller(func, *(extras + args), **kw)
 diagnostics    File "/opt/python-dependencies/retry/api.py", line 73, in retry_decorator
 diagnostics      return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
 diagnostics    File "/opt/python-dependencies/retry/api.py", line 33, in __retry_internal
 diagnostics      return f()
 diagnostics    File "/opt/python-dependencies/hw_diag/app.py", line 24, in perform_key_provisioning
 diagnostics      if not provision_key():
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/miner_param.py", line 103, in provision_key
 diagnostics      gateway_mfr_result = run_gateway_mfr(["provision"])
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/lock_singleton.py", line 71, in wrapper_lock_ecc
 diagnostics      raise ex
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/lock_singleton.py", line 60, in wrapper_lock_ecc
 diagnostics      raise ex
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/lock_singleton.py", line 57, in wrapper_lock_ecc
 diagnostics      value = func(*args, **kwargs)
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/miner_param.py", line 48, in run_gateway_mfr
 diagnostics      raise ECCMalfunctionException(err_str).with_traceback(e.__traceback__)
 diagnostics    File "/opt/python-dependencies/hm_pyhelper/miner_param.py", line 36, in run_gateway_mfr
 diagnostics      run_gateway_mfr_result = subprocess.run(
 diagnostics    File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
 diagnostics      raise CalledProcessError(retcode, process.args,
 diagnostics  hm_pyhelper.exceptions.ECCMalfunctionException: gateway_mfr exited with a non-zero status
 diagnostics  [2021-12-04 01:06:24 +0000] [8] [INFO] Worker exiting (pid: 8)
 diagnostics  [2021-12-04 01:06:25 +0000] [1] [INFO] Shutting down: Master
 diagnostics  [2021-12-04 01:06:25 +0000] [1] [INFO] Reason: Worker failed to boot.

This is not a useful error message, and causes diagnostics to fail to load.

Instead, we should show an error on the ECC detected part of diagnostics saying False and output on logs saying something like "No ECC device found on 0x60 on I2C bus"

shawaj commented 2 years ago

Previously we had this: https://github.com/NebraLtd/hm-gwmfr/blob/1abdf511c71a59a8c24b411f32a7b2117e17b5da/nebraScript.sh#L3-L12

But we lost the functionality when moving to gateway-mfr-rs and deprecating hm-gwmfr

shawaj commented 2 years ago

Partially solved by #270

shawaj commented 1 year ago

Related to #176

shawaj commented 1 year ago

Related to https://github.com/NebraLtd/hm-pyhelper/issues/216 and https://github.com/NebraLtd/hm-pyhelper/issues/221