Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error checking disk state for /dev/nvme0n1p1 #51

Closed
ond000 opened this issue Jan 6, 2025 · 2 comments
Closed

Error checking disk state for /dev/nvme0n1p1 #51

ond000 opened this issue Jan 6, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@ond000
Copy link
Contributor

ond000 commented Jan 6, 2025

Describe the bug
In HA logs I found this error:

Logger: custom_components.unraid.api.disk_state
Zdroj: custom_components/unraid/api/disk_state.py:175
integrace: UNRAID (dokumentace, problémy)
První výskyt: 13:18:01 (22 výskyty)
Naposledy logováno: 13:36:46

Error checking disk state for /dev/nvme0n1p1: cannot access local variable 'result' where it is not associated with a value
Traceback (most recent call last):
  File "/config/custom_components/unraid/api/disk_state.py", line 175, in get_disk_state
    getattr(result, 'exit_status', 'not_run'),
            ^^^^^^
UnboundLocalError: cannot access local variable 'result' where it is not associated with a value

I run debug a reload integration and this is log for that device:

2025-01-06 13:49:12.499 DEBUG (MainThread) [custom_components.unraid.api.disk_state] Found device path for temp: /dev/nvme0n1p1
2025-01-06 13:49:12.500 DEBUG (MainThread) [custom_components.unraid.api.disk_state] NVMe device /dev/nvme0n1p1: always active
2025-01-06 13:49:12.500 ERROR (MainThread) [custom_components.unraid.api.disk_state] Error checking disk state for /dev/nvme0n1p1: cannot access local variable 'result' where it is not associated with a value
Traceback (most recent call last):
  File "/config/custom_components/unraid/api/disk_state.py", line 175, in get_disk_state
    getattr(result, 'exit_status', 'not_run'),
            ^^^^^^
UnboundLocalError: cannot access local variable 'result' where it is not associated with a value

As I look into disk_state.py, problem is, in code from line 169 is used "result"

            # Log final decision with full context
            _LOGGER.debug(
                "Final state for %s (%s): %s (SMART result: %s, hdparm result: %s)",
                device_path,
                device_type,
                state.value,
                getattr(result, 'exit_status', 'not_run'),
                getattr(result, 'stdout', 'not_run').strip() if hasattr(result, 'stdout') else 'not_run'
            )

But that "result" is filled only in IF part for sata drives (from line 98 to line 159), but for NVMe drives it go to ELSE part where is not filled "result" which is used in both cases in already mentioned debug part from line 169.

This issue is probably not functional, probably it have impact only to logging 😊 so this is low priority.

Expected behavior

Screenshots

Debug Log

Unraid (please complete the following information):

  • Version 6.2.14

Home Assistant (please complete the following information):

  • Version 2025.1.0

Home Assistant installation type (please complete the following information):

  • Docker / Container
  • Virtual Machine
  • Raspberry Pi
  • Baremetal

Additional context

@ond000 ond000 added the bug Something isn't working label Jan 6, 2025
@domalab
Copy link
Owner

domalab commented Jan 7, 2025

@ond000 I updated the disk_state.py file to better handle logging for NVME and SATA drives.

Can you please test and let me know it fixes the issue?

@ond000
Copy link
Contributor Author

ond000 commented Jan 7, 2025

@domalab it helps, error disappear 😊 thanks

@domalab domalab closed this as completed Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants