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

config: add rpctimeout #86

Merged

Conversation

wdstorer-bg
Copy link
Contributor

This PR adds an option to set the lndclient RPCTimeout when initializing lndclient. This gives lndmon users the option to increase the timeout beyond the default 30 seconds in cases where the metrics take longer to return.

Note: If not specified, this argument defaults to 30 seconds, which is the lndclient default.

Additional context:
We use lndmon for our lnd nodes running in Kubernetes and get frequent timeouts due to latency specific to nodes running with a PostgreSQL backend. As such, it often takes longer than 30 seconds for lndmon to gather metrics resulting in our lndmon pods frequently going into a crashloop status. In issue:78 it was suggested that this could be addressed, on the lndmon side, by increasing the lndclient timeout. This seems to be a good workaround for us so I wanted to present this PR for consideration. Thank you!

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Very nice addition, thanks!

config.go Outdated
@@ -29,6 +29,9 @@ type lndConfig struct {
// MacaroonName is the name of the macaroon in macaroon dir to use.
MacaroonName string `long:"macaroonname" description:"The name of our macaroon in macaroon dir to use."`

// RPCTimeout is the timeout for rpc calls to lnd in seconds.
RPCTimeout int `long:"rpctimeout" description:"The timeout for rpc calls to lnd in seconds"`
Copy link
Member

Choose a reason for hiding this comment

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

nit: this can be time.Duration directly instead of int, then the default can be 30 * time.Second.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much!

If I change this to time.Duration that would require the user to specify a unit like: 60s. Is that OK? Or is it better to abstract this from the user so they only have to enter an int?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think that's okay. Perhaps we should add a hint to the description, in lnd we use a text like this: Valid time units are {s, m, h}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, that makes sense. Thanks for the reference to lnd. I've pushed the update.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Just need to run make fmt, then this looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

LGTM⚡

@GeorgeTsagk GeorgeTsagk merged commit af15c30 into lightninglabs:master Sep 12, 2022
@wdstorer-bg wdstorer-bg deleted the BG-52292-add-rpctimeout branch September 13, 2022 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants