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

Retrying connecting Influxdb at setup #22567

Merged
merged 5 commits into from
Mar 31, 2019

Conversation

SndR85
Copy link
Contributor

@SndR85 SndR85 commented Mar 30, 2019

Description:

This change makes the Influxdb setup more robust. I had the issue that Influxdb itself started slower than Home-Assistant, even with max_retries set That resulted in a not functioning Influxdb component. I thought max_retries should fix this, but I saw that setting max_retries only affects at the moment of writing to Influxdb, not in setup(). With this change, the max_retries is also used at setup time.

There is no config change with current change.

@SndR85 SndR85 requested a review from fabaff as a code owner March 30, 2019 18:06
@homeassistant
Copy link
Contributor

Hello @scornelissen85,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting Author Name and email@address.com for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

@ghost ghost added the in progress label Mar 30, 2019
@SndR85 SndR85 force-pushed the influxdb-setup-tries branch from df53634 to 4a8da64 Compare March 30, 2019 19:14
@homeassistant
Copy link
Contributor

Hi @scornelissen85,

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!

@dgomes
Copy link
Contributor

dgomes commented Mar 30, 2019

We already have a way for reconnecting to servers when they are not ready.

you should just raise PlatformNotReady

check existing home-assistant components that implement this (e.g. dlna_dmr)

@amelchio is right, sorry ☹️

@amelchio
Copy link
Contributor

Since this is not an entity platform, PlatformNotReady will not work.

Copy link
Contributor

@amelchio amelchio left a comment

Choose a reason for hiding this comment

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

Hello and welcome 😀. This approach is unfortunately not acceptable.

In the except handler, you can use homeassistant.helpers.event.call_later() to schedule another setup() something like one minute later and then just return True

Let me know if you need help with that :)

except (exceptions.InfluxDBClientError, IOError,
requests.exceptions.ConnectionError) as exc:
if retry < max_tries:
time.sleep(RETRY_DELAY)
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not yet on the InfluxThread, so we are not allowed to sleep here (since it blocks other tasks from using this thread).

@SndR85
Copy link
Contributor Author

SndR85 commented Mar 31, 2019

Thanks for your input. I will change it to using homeassistant.helpers.event.call_later(), as that will not block the main thread I guess. I noticed that the sleep in setup slows down the startup, as amelchio noticed.

Should I made a new PR?

@amelchio
Copy link
Contributor

That is up to you, feel free to keep pushing to this one.

_LOGGER.warning("Database host is not accessible due to '%s', please "
"check your entries in the configuration file (host, "
"port, etc.) and verify that the database exists and is "
"READ/WRITE. Retrying again in %s sec.", exc, RETRY_INTERVAL)

Choose a reason for hiding this comment

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

line too long (85 > 79 characters)

return False
_LOGGER.warning("Database host is not accessible due to '%s', please "
"check your entries in the configuration file (host, "
"port, etc.) and verify that the database exists and is "

Choose a reason for hiding this comment

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

line too long (81 > 79 characters)

@@ -39,6 +39,7 @@
TIMEOUT = 5
RETRY_DELAY = 20
QUEUE_BACKLOG_SECONDS = 30
RETRY_INTERVAL = 60 # seconds

Choose a reason for hiding this comment

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

at least two spaces before inline comment

Copy link
Contributor

@amelchio amelchio left a comment

Choose a reason for hiding this comment

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

Yes, this is better 👍. Just a couple of small comments.

)
event_helper.call_later(
hass, RETRY_INTERVAL, lambda _: setup(hass, config)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should return True here or the code below will create a new thread for each retry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it by my latest commit

"Database host is not accessible due to '%s', please "
"check your entries in the configuration file (host, "
"port, etc.) and verify that the database exists and is "
"READ/WRITE. Retrying again in %s sec.", exc, RETRY_INTERVAL
Copy link
Contributor

Choose a reason for hiding this comment

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

Please type out "seconds"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it by my latest commit

Copy link
Contributor

@amelchio amelchio left a comment

Choose a reason for hiding this comment

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

Nice 👍

@cgarwood cgarwood merged commit 7d7b931 into home-assistant:dev Mar 31, 2019
@SndR85
Copy link
Contributor Author

SndR85 commented Apr 8, 2019

Just a small question, maybe more general about the release process. When will this PR being released in stable Home Assistant?

@amelchio
Copy link
Contributor

amelchio commented Apr 8, 2019

April 17th.

There is a release every two weeks and before that you must spend a week in beta. You missed the previous beta by a few days.

This PR will be in the beta that ships about two days from now and it will be in stable a week after that (releases are in the middle of the week, usually Wednesday).

@SndR85
Copy link
Contributor Author

SndR85 commented Apr 13, 2019

Thanks

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Apr 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants