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

test: make nodes also restart after upgrading in knuu #3556

Merged
merged 4 commits into from
Jun 21, 2024

Conversation

cmwaters
Copy link
Contributor

Closes: #3337

@cmwaters
Copy link
Contributor Author

Currently dealing with this error:

E0612 12:34:54.754686   51154 portforward.go:409] an error occurred forwarding 49552 -> 9090: error forwarding port 9090 to pod c1fa51134fec5c9363b80fa36a57202e3c208bbe37128429d0eea31ad1662cb7, uid : network namespace for sandbox "c1fa51134fec5c9363b80fa36a57202e3c208bbe37128429d0eea31ad1662cb7" is closed
test-e2e2024/06/12 12:36:11 --- ERROR MajorUpgradeToV2: expected context.Canceled error, got: sequence 0: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:49552: connect: connection refused"

@evan-forbes
Copy link
Member

evan-forbes commented Jun 12, 2024

would there be any tradeoffs in running this in testnode?

@cmwaters
Copy link
Contributor Author

would there be any tradeoffs in running this in testnode?

  1. cmd/celestia-appd (i.e. our exported binary) and testnode have different ways of constructing the node and running them
  2. There may be incongruences between crashing a node (and the process that was running it) and programatically stopping and starting a node)
  3. testnode is only equipped for running single node networks (so far) which wouldn't emulate what would happen if the network still progressed and the node had to catch up.

Outside of these three, I would think it's relatively similar

@cmwaters cmwaters added the warn:blocked item is not currently being worked on but is still blocked label Jun 13, 2024
@cmwaters
Copy link
Contributor Author

I may be mistaken, but I think this is blocked on #3505 and potential other changes that can avoid the port forwarding errors that arise

@cmwaters cmwaters marked this pull request as ready for review June 20, 2024 12:52
@cmwaters cmwaters requested a review from a team as a code owner June 20, 2024 12:52
@cmwaters cmwaters requested review from ramin and staheri14 and removed request for a team June 20, 2024 12:52
Copy link
Contributor

coderabbitai bot commented Jun 20, 2024

Walkthrough

This update modifies the MajorUpgradeToV2 function in major_upgrade_v2.go to change the upgradeHeight value, introduce a loop iteration change, and add a new block of code to restart nodes and verify progress during the upgrade process. These changes aim to create a more robust end-to-end test by tackling potential issues related to restarting nodes.

Changes

Files Change Summary
test/e2e/major_upgrade_v2.go Change upgradeHeight from 12 to 10, add code block for restarting nodes, and adjust loop iteration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Logger
    participant Application

    User ->> Application: Calls MajorUpgradeToV2(logger)
    Application ->> Logger: Logs Upgrade Initiation
    Application ->> Application: Set upgradeHeight to 10
    loop Upgrade Process
        Application ->> Application: Perform upgrade steps
        Application ->> Logger: Log Progress
    end
    Application ->> Application: Restart Nodes
    Application ->> Logger: Log restart verification
    Application ->> User: Returns upgrade completion status
Loading

Assessment against linked issues

Objective Addressed Explanation
Unit or e2e test that starts, stops, and restarts a node (#3337)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@cmwaters
Copy link
Contributor Author

This is passing for me locally now

@cmwaters cmwaters removed the warn:blocked item is not currently being worked on but is still blocked label Jun 20, 2024
@@ -60,6 +60,7 @@ func MajorUpgradeToV2(logger *log.Logger) error {

heightBefore := upgradeHeight - 1
for i := 0; i < numNodes; i++ {

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

@celestia-bot celestia-bot requested a review from a team June 20, 2024 15:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Comment on lines +83 to +100
// make all nodes in the network restart and ensure that progress is still made
for _, node := range testNet.Nodes() {
client, err := node.Client()
testnet.NoError("failed to get client", err)

height, err := getHeight(ctx, client, time.Minute)
if err != nil {
return fmt.Errorf("failed to get height: %w", err)
}

if err := node.Upgrade(latestVersion); err != nil {
return fmt.Errorf("failed to restart node: %w", err)
}

if err := waitForHeight(ctx, client, height+3, time.Minute); err != nil {
return fmt.Errorf("failed to wait for height: %w", err)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider simplifying the loop for node restarts. Currently, it checks heights and restarts nodes sequentially, which could be parallelized for efficiency.

- for _, node := range testNet.Nodes() {
-     client, err := node.Client()
-     testnet.NoError("failed to get client", err)
-     height, err := getHeight(ctx, client, time.Minute)
-     if err != nil {
-         return fmt.Errorf("failed to get height: %w", err)
-     }
-     if err := node.Upgrade(latestVersion); err != nil {
-         return fmt.Errorf("failed to restart node: %w", err)
-     }
-     if err := waitForHeight(ctx, client, height+3, time.Minute); err != nil {
-         return fmt.Errorf("failed to wait for height: %w", err)
-     }
- }
+ // Parallelize node restarts for efficiency
+ errGroup := new(errgroup.Group)
+ for _, node := range testNet.Nodes() {
+     node := node // capture range variable
+     errGroup.Go(func() error {
+         client, err := node.Client()
+         if err != nil {
+             return fmt.Errorf("failed to get client: %w", err)
+         }
+         height, err := getHeight(ctx, client, time.Minute)
+         if err != nil {
+             return err
+         }
+         if err := node.Upgrade(latestVersion); err != nil {
+             return fmt.Errorf("failed to restart node: %w", err)
+         }
+         return waitForHeight(ctx, client, height+3, time.Minute)
+     })
+ }
+ if err := errGroup.Wait(); err != nil {
+     return err
+ }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// make all nodes in the network restart and ensure that progress is still made
for _, node := range testNet.Nodes() {
client, err := node.Client()
testnet.NoError("failed to get client", err)
height, err := getHeight(ctx, client, time.Minute)
if err != nil {
return fmt.Errorf("failed to get height: %w", err)
}
if err := node.Upgrade(latestVersion); err != nil {
return fmt.Errorf("failed to restart node: %w", err)
}
if err := waitForHeight(ctx, client, height+3, time.Minute); err != nil {
return fmt.Errorf("failed to wait for height: %w", err)
}
}
// Parallelize node restarts for efficiency
errGroup := new(errgroup.Group)
for _, node := range testNet.Nodes() {
node := node // capture range variable
errGroup.Go(func() error {
client, err := node.Client()
if err != nil {
return fmt.Errorf("failed to get client: %w", err)
}
height, err := getHeight(ctx, client, time.Minute)
if err != nil {
return err
}
if err := node.Upgrade(latestVersion); err != nil {
return fmt.Errorf("failed to restart node: %w", err)
}
return waitForHeight(ctx, client, height+3, time.Minute)
})
}
if err := errGroup.Wait(); err != nil {
return err
}

}

if err := node.Upgrade(latestVersion); err != nil {
return fmt.Errorf("failed to restart node: %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[optional]

Suggested change
return fmt.Errorf("failed to restart node: %w", err)
return fmt.Errorf("failed to upgrade node: %w", err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know the function says upgrade, but it's actually upgrading to the same version, effectively a restart. It could be cleaner if we just have a Restart method in testnet that does the same thing

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 restart would be clearer in that case

@celestia-bot celestia-bot requested a review from a team June 21, 2024 08:20
@cmwaters cmwaters merged commit c858961 into main Jun 21, 2024
32 checks passed
@cmwaters cmwaters deleted the cal/restart-v2-e2e branch June 21, 2024 09:14
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.

Add a test to restart the app
5 participants