Skip to content

Fix asuswrt network failure startup#33485

Merged
MartinHjelmare merged 22 commits intohome-assistant:devfrom
ollo69:asuswrt-startup-fix
Apr 3, 2020
Merged

Fix asuswrt network failure startup#33485
MartinHjelmare merged 22 commits intohome-assistant:devfrom
ollo69:asuswrt-startup-fix

Conversation

@ollo69
Copy link
Copy Markdown
Contributor

@ollo69 ollo69 commented Apr 1, 2020

Proposed change

Fix for issue ##33284 - Asuswrt component fail at startup after power failure.
Manage exception during component initialization and raise "PlatformNotReady if exception is type "OSError" (typically will be: [Errno 101] Network is unreachable)

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@probot-home-assistant probot-home-assistant Bot added integration: asuswrt small-pr PRs with less than 30 lines. labels Apr 1, 2020
@homeassistant
Copy link
Copy Markdown
Contributor

Hi @ollo69,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@probot-home-assistant
Copy link
Copy Markdown

Hey there @kennedyshead, mind taking a look at this pull request as its been labeled with a integration (asuswrt) you are listed as a codeowner for? Thanks!

Comment thread homeassistant/components/asuswrt/__init__.py Outdated
Comment thread homeassistant/components/asuswrt/__init__.py Outdated
Comment thread homeassistant/components/asuswrt/__init__.py Outdated
Comment thread homeassistant/components/asuswrt/__init__.py Outdated
@MartinHjelmare MartinHjelmare changed the title Fix network failure startup Fix asuswrt network failure startup Apr 2, 2020
Comment thread homeassistant/components/asuswrt/__init__.py Outdated
Comment thread homeassistant/components/asuswrt/__init__.py
@ollo69 ollo69 force-pushed the asuswrt-startup-fix branch from 2ea8e52 to 9b5d9e8 Compare April 2, 2020 13:59
Comment thread homeassistant/components/asuswrt/__init__.py Outdated
Comment thread homeassistant/components/asuswrt/__init__.py Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Copy Markdown
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the test_specify_non_directory_path_for_dnsmasq test is failing

Comment thread homeassistant/components/asuswrt/__init__.py
Comment thread tests/components/asuswrt/test_device_tracker.py
Comment thread tests/components/asuswrt/test_device_tracker.py Outdated
Comment thread tests/components/asuswrt/test_device_tracker.py Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

There is potential for making the tests more robust. That can be a future PR.

hass, DOMAIN, {DOMAIN: {CONF_HOST: "fake_host", CONF_USERNAME: "fake_user"}}
)
assert result
assert hass.data.get(DATA_ASUSWRT, None) is None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if we tested the existence of states in the state machine. When there's an error there shouldn't be any states. After the error clears, the setup should complete and states be created. That way we don't rely on the details of our implementation in the tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will keeep in consideration for next PR. Thx

@MartinHjelmare MartinHjelmare added this to the 0.108.0 milestone Apr 3, 2020
@MartinHjelmare MartinHjelmare merged commit 62835f0 into home-assistant:dev Apr 3, 2020
@ollo69 ollo69 deleted the asuswrt-startup-fix branch April 3, 2020 13:11
balloob pushed a commit that referenced this pull request Apr 3, 2020
* Fix network failure startup

Fix for issue ##33284 - Asuswrt component fail at startup after power failure

* Removed comment

* Removed bare except

* is_connected moved out try-catch

* Removed pointless-string-statement

* Raise PlatformNotReady on "not is_connected"

* Removed unnecessary check

* Revert "Removed unnecessary check"

This reverts commit a2ccdda.

* Implemented custom retry mechanism

* Fix new line missing

* Fix formatting

* Fix indent

* Reviewed check

* Recoded based on tibber implementation

* Formatting review

* Changes requested

* Fix tests for setup retry

* Updated missing test

* Fixed check on Tests

* Return false if not exception

* Format correction
@lock lock Bot locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asuswrt component fail at startup after power failure

7 participants