NebraLtd / hm-diag

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

UnboundLocalError: local variable 'public_keys' referenced before assignment #243

Closed KevinWassermann94 closed 2 years ago

KevinWassermann94 commented 2 years ago

Haven't seen this one before. https://dashboard.balena-cloud.com/devices/dd264dbaff9d6f4f31306e440ed89504/summary

22.11.21 14:34:58 (+0100)  diagnostics  DEBUG:flask_caching.backends.simplecache:get key 'view//initFile.txt' -> miss 
22.11.21 14:34:59 (+0100)  diagnostics  2021-11-22 13:34:59,041 - [INFO] - hm_pyhelper.miner_param - (miner_param.py).run_gateway_mfr -- /usr/local/lib/python3.10/site-packages/hm_pyhelper/miner_param.py:(40) - 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'
22.11.21 14:34:59 (+0100)  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'
22.11.21 14:34:59 (+0100)  diagnostics  2021-11-22 13:34:59,043 - [INFO] - hm_pyhelper.miner_param - (miner_param.py).run_gateway_mfr -- /usr/local/lib/python3.10/site-packages/hm_pyhelper/miner_param.py:(42) - gateway_mfr response stderr: b''
22.11.21 14:34:59 (+0100)  diagnostics  INFO:hm_pyhelper.miner_param:gateway_mfr response stderr: b''
22.11.21 14:34:59 (+0100)  diagnostics  setting BT to True
22.11.21 14:34:59 (+0100)  diagnostics  2021-11-22 13:34:59,172 - [ERROR] - hm_pyhelper.miner_param - (miner_param.py).run_gateway_mfr -- /usr/local/lib/python3.10/site-packages/hm_pyhelper/miner_param.py:(46) - gateway_mfr exited with a non-zero status
22.11.21 14:34:59 (+0100)  diagnostics  Traceback (most recent call last):
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/hm_pyhelper/miner_param.py", line 35, in run_gateway_mfr
22.11.21 14:34:59 (+0100)  diagnostics      run_gateway_mfr_result = subprocess.run(
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
22.11.21 14:34:59 (+0100)  diagnostics      raise CalledProcessError(retcode, process.args,
22.11.21 14:34:59 (+0100)  diagnostics  subprocess.CalledProcessError: Command '['/usr/local/lib/python3.10/site-packages/hm_pyhelper/gateway_mfr', 'key', '0']' returned non-zero exit status 1.
22.11.21 14:34:59 (+0100)  diagnostics  ERROR:hm_pyhelper.miner_param:gateway_mfr exited with a non-zero status
22.11.21 14:34:59 (+0100)  diagnostics  Traceback (most recent call last):
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/hm_pyhelper/miner_param.py", line 35, in run_gateway_mfr
22.11.21 14:34:59 (+0100)  diagnostics      run_gateway_mfr_result = subprocess.run(
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
22.11.21 14:34:59 (+0100)  diagnostics      raise CalledProcessError(retcode, process.args,
22.11.21 14:34:59 (+0100)  diagnostics  subprocess.CalledProcessError: Command '['/usr/local/lib/python3.10/site-packages/hm_pyhelper/gateway_mfr', 'key', '0']' returned non-zero exit status 1.
22.11.21 14:34:59 (+0100)  diagnostics  ERROR:hw_diag:Exception on /initFile.txt [GET]
22.11.21 14:34:59 (+0100)  diagnostics  Traceback (most recent call last):
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2070, in wsgi_app
22.11.21 14:34:59 (+0100)  diagnostics      response = self.full_dispatch_request()
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1515, in full_dispatch_request
22.11.21 14:34:59 (+0100)  diagnostics      rv = self.handle_user_exception(e)
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1513, in full_dispatch_request
22.11.21 14:34:59 (+0100)  diagnostics      rv = self.dispatch_request()
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1499, in dispatch_request
22.11.21 14:34:59 (+0100)  diagnostics      return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/flask_caching/__init__.py", line 475, in decorated_function
22.11.21 14:34:59 (+0100)  diagnostics      rv = f(*args, **kwargs)
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/hw_diag-1.0-py3.10.egg/hw_diag/views/diagnostics.py", line 91, in get_initialisation_file
22.11.21 14:34:59 (+0100)  diagnostics      diagnostics_report.perform_diagnostics()
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/hm_pyhelper/diagnostics/diagnostics_report.py", line 53, in perform_diagnostics
22.11.21 14:34:59 (+0100)  diagnostics      diagnostic.perform_test(self)
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/hw_diag-1.0-py3.10.egg/hw_diag/diagnostics/key_diagnostics.py", line 61, in perform_test
22.11.21 14:34:59 (+0100)  diagnostics      key_diagnostic.perform_test(diagnostics_report)
22.11.21 14:34:59 (+0100)  diagnostics    File "/usr/local/lib/python3.10/site-packages/hw_diag-1.0-py3.10.egg/hw_diag/diagnostics/key_diagnostics.py", line 42, in perform_test
22.11.21 14:34:59 (+0100)  diagnostics      diagnostics_report.record_result(public_keys[self.key_path], self)
22.11.21 14:34:59 (+0100)  diagnostics  UnboundLocalError: local variable 'public_keys' referenced before assignment
shawaj commented 2 years ago

So that's the ECC tests failing / timing out and therefore it can't get the public key and fails.

Should be handled better for sure and relates to #239 - does the diagnostics show the same on the page?

KevinWassermann94 commented 2 years ago

@shawaj Yes the diagnostics page is showing the same as #239

shawaj commented 2 years ago

This can happen for a number of reasons:

KevinWassermann94 commented 2 years ago

@shawaj What do you reckon we should do with units this is happening on? Do you think there is an actual issue with the ECC? https://dashboard.balena-cloud.com/devices/dd264dbaff9d6f4f31306e440ed89504/summary https://dashboard.balena-cloud.com/devices/6821ec75d58981221f16e420a014b3a2/summary

salmanfarisvp commented 2 years ago

Wayne reported two devices with similar issues.

tried an I2C scan for ECC, but nothing was found.

image

vpetersson commented 2 years ago

That's very concerning and I'm almost inclined to say that this is a hardware issue.

shawaj commented 2 years ago

That's very concerning and I'm almost inclined to say that this is a hardware issue.

I would be very surprised if an ECC failed.

Are these brand new devices - have they been onboarded to network? Indoor/outdoor?

Kerrryu commented 2 years ago

This error seems to closely relate to the one on #239 as stated above, which has been handled in the PR related to that issue. If we wanted to test for a more clear error message I believe we would have to modify the gateway_mfr repo as it seems like hm_pyhelper only returns results from there and doesn't calculate anything on that end.

marvinmarnold commented 2 years ago

This can be closed as it has already been solved.