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

debug api basic and full routing #1358

Merged
merged 3 commits into from
Mar 2, 2021
Merged

debug api basic and full routing #1358

merged 3 commits into from
Mar 2, 2021

Conversation

janos
Copy link
Member

@janos janos commented Mar 1, 2021

This PR introduces a two step Debug API router configuration.

Currently, debug api http listener is exposed at the end of the node starting process, when all of the services are constructed. This is a problem if there is a long running process, like localstore migration, and the /health endpoint is not exposed for a long time for kubernetes health check. This PR creates a debug api listener at the start of node initialization, exposing /health, /addresses and some other available debug endpoints, like metrics, pprof and vars. After all of the debug api dependencies are constructed, debug api service is configured with them and a full router is set.

This PR is with the minimal set of changes for this to be accomplished. A followup PR can be done to remove debugapi.Service interface and expose server in that package to avoid Configure method to be in the interface also. The interface is not needed. This change would require to unexport fields in the server struct which would raise the number of changed lines significantly here. I am avoiding that.

@janos janos added the in progress ongoing development , hold out with review label Mar 1, 2021
@janos janos requested review from acud, zelig and svetomir March 1, 2021 18:32
@janos janos added ready for review The PR is ready to be reviewed and removed in progress ongoing development , hold out with review labels Mar 1, 2021
@janos janos self-assigned this Mar 1, 2021
@@ -30,33 +31,32 @@ import (

type Service interface {
http.Handler
Configure(overlay swarm.Address, publicKey, pssPublicKey ecdsa.PublicKey, ethereumAddress common.Address, p2p p2p.DebugService, pingpong pingpong.Interface, topologyDriver topology.Driver, storer storage.Storer, tags *tags.Tags, accounting accounting.Interface, settlement settlement.Interface, chequebookEnabled bool, swap swap.ApiInterface, chequebook chequebook.Service)
Copy link
Member Author

Choose a reason for hiding this comment

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

As explained in PR description, this interface should be removed for simplification and to avoid to have this method here.

@Eknir
Copy link
Contributor

Eknir commented Mar 2, 2021

Hey Janos: This is related: #1295 Can that be completed after your PR?

Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

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

Very cool 👏 Thanks @janos

// to expose /health endpoint, Go metrics and pprof. It is useful to expose
// these endpoints before all dependencies are configured and injected to have
// access to basic debugging tools and /health endpoint.
func New(logger logging.Logger, tracer *tracing.Tracer, corsAllowedOrigins []string) Service {
Copy link
Member

Choose a reason for hiding this comment

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

Minor suggestion: I think that overlay swarm.Address, publicKey, pssPublicKey ecdsa.PublicKey, ethereumAddress common.Address can already be set in this constructor as they are static and not expected to change during runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a very good suggestion. The only problem is ethereumAddress common.Address which needs to wait for InitChain function to complete. I am suggesting to have explicit SetEthereumAddress method and move other address arguments to constructor as you suggested. The EthereumAddress would require lock, but that is not so drastic.

This way there would be a debug api available as soon as possible for debugging and health and also with /addresses endpoint exposed, but ethereum address would be set only if and after InitChain is done. This would address some of the points in #1295 that @Eknir mentioned. WTYT @acud @Eknir?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I don't think that you need InitChain for this. You can have the ethereum address from the signer which is passed to NewBee, exactly as it is used in InitChain

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, correct. Great. :)

@janos
Copy link
Member Author

janos commented Mar 2, 2021

PR is updated to expose /addresses on node start before all other services which is a nice consequence of the change suggested by @acud.

The documentation should be updated with the new behaviour after this PR is merged. Underlay addresses array in /addresses response is empty until p2p service is constructed, including the nat relay.

@janos janos requested review from acud and svetomir March 2, 2021 11:26
Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

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

👏

@janos janos merged commit 7d4976d into master Mar 2, 2021
@janos janos deleted the debugapi-basic-routing branch March 2, 2021 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull-request ready for review The PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants