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

Fix retry when Met config entry fails #70012

Merged
merged 3 commits into from
Apr 16, 2022

Conversation

chemelli74
Copy link
Contributor

@chemelli74 chemelli74 commented Apr 13, 2022

Proposed change

Handle when upstream fetching_data() fails: need to raise an exception as the method return only true/false.

Meanwhile, also the api URL is updated based on the official documentation (old one gives timeout 99% of the time)

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

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

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

Hey there @Danielhiversen, @thimic, mind taking a look at this pull request as it has been labeled with an integration (met) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

Comment on lines 37 to 38
# From https://api.met.no/weatherapi/locationforecast/2.0/documentation
URL = "https://api.met.no/weatherapi/locationforecast/2.0/complete"
Copy link
Member

@frenck frenck Apr 13, 2022

Choose a reason for hiding this comment

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

We cannot change this. As we are a heavy traffic consumer, we have been assigned a different end-point.
(I think...)

Copy link
Member

Choose a reason for hiding this comment

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

Yep: #59554 & #39583

Can we put a note above it that explains why it is a custom URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We cannot change this. As we are a heavy traffic consumer, we have been assigned a different end-point.

Gotha, but current URL here timeout 99% of the time :-S

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for tagging you @geira, could you maybe provide insight on that?

Copy link

Choose a reason for hiding this comment

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

The reason Home-Assistant has its own custom subdomain is that the traffic is way above the TOS limit of 20 requests/second, and is currently using about 20% of the total api traffic. For this reason we need to be able to monitor and route traffic to optimize resources. As recently mentioned on our mailing list we are experiencing network problems with slow downloads on the main gateway. Since we have an Easter holiday systems freeze we decided to route the most trafficed subdomains to our standby gateway which previously had been running idle, until we can set up a new redundant pair of servers to balance the load. Please do not use momentary statistics taken during a notified emergency as an excuse to circumvent the TOS.

Copy link
Member

@frenck frenck Apr 15, 2022

Choose a reason for hiding this comment

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

Right, so it is a service disruption, thanks for that valuable information that is appreciated.

Please do not use momentary statistics taken during a notified emergency as an excuse to circumvent the TOS.

Nobody said we would, the review is preventing it even and we reach out to understand why the assigned endpoint isn't functioning.

Please don't approach things from a negative context and throw around TOS policies and such. We are just asking and reaching out.

Have a great Easter weekend @geira 🥚 🐰

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a note for the future.

Copy link
Member

Choose a reason for hiding this comment

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

That is helpful, thanks @chemelli74 👍

@chemelli74 chemelli74 added this to the 2022.4.5 milestone Apr 15, 2022
await self._weather_data.fetching_data()
resp = await self._weather_data.fetching_data()
if not resp:
raise asyncio.TimeoutError
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this is an asyncio error, which is kinda awkward to raise here? As in, that is not managed by us.

Maybe raise a custom error (from HomeAssistantError) or UpdateFailed instead?

Copy link
Member

Choose a reason for hiding this comment

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

As far as I understand this update function is used only here:

return await self.weather.fetch_data()

I think it would be better to move this fetching part directly there and raise raise UpdateFailed instead of raising here and raising again.
Another option is to change the return type to allow None

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @chemelli74 👍

@frenck frenck merged commit 0f8595e into home-assistant:dev Apr 16, 2022
frenck pushed a commit that referenced this pull request Apr 16, 2022
@frenck frenck mentioned this pull request Apr 16, 2022
@chemelli74 chemelli74 deleted the chemelli74-met-timeout branch April 16, 2022 19:29
@github-actions github-actions bot locked and limited conversation to collaborators Apr 17, 2022
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.

6 participants