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

BE-696 | Feature request to improve service recovery after restart #624

Open
wants to merge 1 commit into
base: v28.x
Choose a base branch
from

Conversation

deividaspetraitis
Copy link
Member

@deividaspetraitis deividaspetraitis commented Mar 9, 2025

This PR enables to start SQS service without early exit when Node is not available.
New behaviour is controlled with configuration variable to avoid discrepancies for the current setup with a defaults for early exit.

Feature can be tested with following command:

SQS_SKIP_CHAIN_AVAILABILITY_CHECK=true go run app/*.go

Note: we don't need here any additional mechanisms since auto reconnect is handled by gRPC.

Summary by CodeRabbit

  • New Features
    • Introduced a configurable option to control the behavior when chain availability issues occur.
  • Bug Fixes
    • Enhanced error handling across critical processes to log errors gracefully rather than causing abrupt application terminations.
    • Adjusted the error handling flow during startup to improve overall application robustness.

This PR enables to start SQS service without early exit when Node is not
available.
New behaviour is controlled with configuration variable to avoid discrepancies for the current setup
with a defaults for early exit.

Feature can be tested with following command:

```bash
SQS_SKIP_CHAIN_AVAILABILITY_CHECK=true go run app/*.go
```
Copy link

sonarqubecloud bot commented Mar 9, 2025

Copy link
Contributor

coderabbitai bot commented Mar 9, 2025

Walkthrough

The changes improve error handling and configuration in the application. The error handling in the main function now conditionally logs errors from the blockchain client based on a configuration flag, instead of always panicking. Similarly, the sidecar query server now logs errors from the gRPC gateway status check. In addition, a new configuration field has been introduced to allow skipping the chain availability check.

Changes

File(s) Change Summary
app/main.go, app/sidecar_query_server.go Modified error handling: In main.go, errors from chainClient.GetLatestHeight now conditionally log errors based on a config flag and the initialization order was adjusted. In sidecar_query_server.go, errors from the gRPC gateway are logged instead of being returned immediately.
domain/config.go Added a new boolean field SkipChainAvailabilityCheck with a default value false to enable configurable chain availability checks.

Sequence Diagram(s)

sequenceDiagram
    participant Main
    participant ChainClient
    participant Config
    participant Logger

    Main->>ChainClient: GetLatestHeight(ctx)
    ChainClient-->>Main: Error occurs
    Main->>Config: Check SkipChainAvailabilityCheck flag
    alt Flag is false
       Main->>Main: Panic
    else Flag is true
       Main->>Logger: Log the error
    end
Loading
sequenceDiagram
    participant SidecarQS as SidecarQueryServer
    participant GRPCGateway
    participant Logger

    SidecarQS->>GRPCGateway: checkGRPCGatewayStatus()
    GRPCGateway-->>SidecarQS: Error occurs
    SidecarQS->>Logger: Log error ("Error checking grpc gateway status")
Loading

Suggested reviewers

  • p0mvn
  • PaddyMc

Poem

I'm a rabbit in the code, so bright,
Hopping through logic deep into the night.
Errors once made me pause and sigh,
Now I log them as they pass by.
With each graceful leap, my code sings,
A joyful dance of pointed strings!
(_/)> Let's hop on!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8bc4ba and ce25ef3.

📒 Files selected for processing (3)
  • app/main.go (2 hunks)
  • app/sidecar_query_server.go (1 hunks)
  • domain/config.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (5)
domain/config.go (2)

34-34: LGTM: New configuration option added for service resilience.

The new SkipChainAvailabilityCheck boolean field with appropriate mapstructure tag allows for configurable error handling when the chain is unavailable.


76-76: LGTM: Safe default value.

Setting the default value to false ensures backward compatibility with existing behavior, requiring explicit opt-in for the new error handling approach.

app/sidecar_query_server.go (1)

146-146: Improved error handling for gRPC gateway status check.

Rather than returning an error which could halt application startup, you're now logging the error and allowing the service to continue. This aligns with the PR objective to improve service recovery when dependent services are unavailable.

app/main.go (2)

118-123: Conditional error handling based on configuration.

Great implementation of configurable error handling based on the new SkipChainAvailabilityCheck option. This allows for more graceful handling of situations where the blockchain node is temporarily unavailable while maintaining backward compatibility with the default behavior.


144-144: Improved error handling for server startup.

Logging the error rather than panicking allows for more graceful error reporting and potentially better diagnostic information when issues occur during startup.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator

@pablin-10 pablin-10 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants