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

[api] API delay before readiness #4516

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Dec 6, 2024

Description

The original intention was to ensure that all transactions that were not received during the restart were already included in block, thereby avoiding inconsistencies in the state of the API node.

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@envestcc
Copy link
Member Author

envestcc commented Dec 6, 2024

Attentions during deployment: as it may increase the service's readiness time. We need to adjust accordingly the maximum tolerance time for the readiness probe

@@ -27,6 +29,8 @@ type Config struct {
WebsocketRateLimit int `yaml:"websocketRateLimit"`
// ListenerLimit is the maximum number of listeners.
ListenerLimit int `yaml:"listenerLimit"`
// ReadyDuration is the duration to wait for the server to be ready.
ReadyDuration time.Duration `yaml:"readyDuration"`
Copy link
Member

Choose a reason for hiding this comment

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

where is this value set? I also don't see a default value

Copy link
Member Author

Choose a reason for hiding this comment

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

0 is default value, which means no delay

@@ -231,9 +232,18 @@ func StartServer(ctx context.Context, svr *Server, probeSvr *probe.Server, cfg c
log.L().Panic("Failed to stop server.", zap.Error(err))
}
}()
if cfg.API.ReadyDuration > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

which apis or functions will be impacted? any of them could be started? e.g., heartbeat

Copy link
Member Author

Choose a reason for hiding this comment

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

The waiting occurs after all lifecycle items (e.g., API, P2P) have already started, except for the heartBeat logging and admin API(for debug).

From an external perspective:

  • P2P is already ready and can receive blocks and actions.
  • The API(e.g. http, grpc, wss) is not ready because the GET /readiness returns 503.

Copy link

sonarcloud bot commented Dec 9, 2024

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.

3 participants