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

feat(auto-salvage): v2 support #3170

Merged
merged 5 commits into from
Nov 6, 2024

Conversation

c3y1huang
Copy link
Contributor

Which issue(s) this PR fixes:

Issue longhorn/longhorn#8430

What this PR does / why we need it:

Support auto-salvage for v2 volumes.

Special notes for your reviewer:

None

Additional documentation or context

None

@c3y1huang c3y1huang self-assigned this Sep 19, 2024
@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 82f0307 to f93085b Compare September 19, 2024 09:00
Copy link

mergify bot commented Sep 22, 2024

This pull request is now in conflict. Could you fix it @c3y1huang? 🙏

@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch 3 times, most recently from 66f7725 to 5aec546 Compare September 27, 2024 02:14
go.mod Outdated Show resolved Hide resolved
@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 5aec546 to 88859ee Compare September 27, 2024 05:22
@c3y1huang c3y1huang marked this pull request as ready for review September 27, 2024 05:35
@c3y1huang c3y1huang requested review from derekbit, shuo-wu and a team September 27, 2024 05:36
@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 88859ee to 5cb12ad Compare September 27, 2024 08:06
@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 5cb12ad to 4a76f0f Compare October 24, 2024 09:32
Copy link

coderabbitai bot commented Oct 24, 2024

Walkthrough

The pull request introduces several modifications across three files, focusing on enhancing volume management and synchronization processes. Key changes include the unconditional setting of the SalvageRequested flag in the ReconcileVolumeState method of the VolumeController, the addition of a SalvageRequested field in the EngineCreateRequest structure, and the implementation of error handling in the TrimFilesystem method of the VolumeManager. These updates aim to improve the handling of volume states, particularly in scenarios requiring salvage operations, while also refining logging and error reporting mechanisms.

Changes

File Change Summary
controller/volume_controller.go Simplified ReconcileVolumeState method logic; enhanced logging for auto-salvage process; improved error handling in syncVolume method.
engineapi/instance_manager.go Added SalvageRequested field to EngineCreateRequest; updated EngineInstanceUpgrade method for data engine type checks.
manager/volume.go Added error handling in TrimFilesystem method to prevent trimming of degraded v2 volumes; minor formatting adjustments.

Assessment against linked issues

Objective Addressed Explanation
Support auto salvage for v2 volumes (#8430)

Possibly related PRs

Suggested reviewers

  • derekbit
  • shuo-wu

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 39e294e and 3d806c6.

⛔ Files ignored due to path filters (4)
  • go.mod is excluded by !go.mod
  • go.sum is excluded by !**/*.sum, !go.sum
  • vendor/github.com/longhorn/longhorn-instance-manager/pkg/client/instance.go is excluded by !vendor/**
  • vendor/modules.txt is excluded by !vendor/**
📒 Files selected for processing (3)
  • controller/volume_controller.go (2 hunks)
  • engineapi/instance_manager.go (1 hunks)
  • manager/volume.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • controller/volume_controller.go
  • engineapi/instance_manager.go
  • manager/volume.go

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:

  • 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 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.

@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 4a76f0f to b8328b2 Compare October 25, 2024 01:40
Copy link

mergify bot commented Oct 26, 2024

This pull request is now in conflict. Could you fix it @c3y1huang? 🙏

@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch 5 times, most recently from c87cb79 to 3c1af3e Compare November 1, 2024 07:09
Copy link

@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: 0

🧹 Outside diff range and nitpick comments (1)
controller/volume_controller.go (1)

1391-1391: Improve log message clarity

The log message could be more descriptive to indicate the auto-salvage operation.

-log.Infof("Bringing up %v replicas for auto-salvage", len(failedUsableReplicas))
+log.Infof("Auto-salvaging %v failed but usable replicas", len(failedUsableReplicas))
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b8328b2 and 3c1af3e.

⛔ Files ignored due to path filters (6)
  • go.mod is excluded by !go.mod
  • go.sum is excluded by !**/*.sum, !go.sum
  • vendor/github.com/longhorn/longhorn-instance-manager/pkg/client/instance.go is excluded by !vendor/**
  • vendor/github.com/longhorn/types/pkg/generated/imrpc/instance.pb.go is excluded by !**/*.pb.go, !**/generated/**, !vendor/**
  • vendor/github.com/longhorn/types/pkg/generated/spdkrpc/spdk.pb.go is excluded by !**/*.pb.go, !**/generated/**, !vendor/**
  • vendor/modules.txt is excluded by !vendor/**
📒 Files selected for processing (3)
  • controller/volume_controller.go (2 hunks)
  • engineapi/instance_manager.go (1 hunks)
  • manager/volume.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • manager/volume.go
🔇 Additional comments (2)
engineapi/instance_manager.go (1)

516-516: LGTM: SalvageRequested field addition

The addition of the SalvageRequested field to the EngineCreateRequest structure properly propagates the salvage request flag from the engine specification to the instance manager.

Let's verify the salvage flag propagation:

✅ Verification successful

Based on the search results, I can now generate the final response as there's sufficient evidence to verify the proper propagation of the SalvageRequested field.

✓ SalvageRequested field is properly integrated

The SalvageRequested field is consistently implemented across the codebase:

  • Properly defined in protobuf specifications (spdk.pb.go and instance.pb.go)
  • Correctly propagated from engine spec to instance manager
  • Integrated with the auto-salvage workflow in volume_controller.go
  • Properly handled in instance lifecycle management (instance_handler.go)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent handling of SalvageRequested across the codebase
rg -A 5 "SalvageRequested" 

Length of output: 9142

controller/volume_controller.go (1)

1336-1337: Unconditional auto-salvage request for failed replicas

The change removes the data engine version check and unconditionally sets e.Spec.SalvageRequested = true when all replicas fail. This change enables auto-salvage support for v2 volumes.

@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 3c1af3e to d000dab Compare November 1, 2024 08:30
Copy link

mergify bot commented Nov 3, 2024

This pull request is now in conflict. Could you fix it @c3y1huang? 🙏

@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch 2 times, most recently from f8ffd7e to 39e294e Compare November 6, 2024 02:51
Copy link

@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

🧹 Outside diff range and nitpick comments (1)
controller/volume_controller.go (1)

Line range hint 1-1924: Consider code structure improvements

While the implementation is functionally correct, consider the following improvements:

  1. Break down large functions like ReconcileVolumeState into smaller, more focused functions
  2. Add package-level documentation explaining the controller's responsibilities
  3. Extract magic numbers into named constants (e.g., retry counts, timeouts)
  4. Add more inline documentation for complex logic sections
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f8ffd7e and 39e294e.

⛔ Files ignored due to path filters (4)
  • go.mod is excluded by !go.mod
  • go.sum is excluded by !**/*.sum, !go.sum
  • vendor/github.com/longhorn/longhorn-instance-manager/pkg/client/instance.go is excluded by !vendor/**
  • vendor/modules.txt is excluded by !vendor/**
📒 Files selected for processing (3)
  • controller/volume_controller.go (2 hunks)
  • engineapi/instance_manager.go (1 hunks)
  • manager/volume.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • engineapi/instance_manager.go
  • manager/volume.go
🔇 Additional comments (1)
controller/volume_controller.go (1)

Line range hint 1391-1401: LGTM: Well-structured error handling and logging

The error handling and logging implementation is robust:

  • Uses structured logging with appropriate context
  • Proper error wrapping and propagation
  • Clear log messages for debugging

controller/volume_controller.go Show resolved Hide resolved
@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 39e294e to 7468162 Compare November 6, 2024 04:01
longhorn/longhorn-8430

Signed-off-by: Chin-Ya Huang <[email protected]>
longhorn/longhorn-8430

Signed-off-by: Chin-Ya Huang <[email protected]>
longhorn/longhorn-8430

Signed-off-by: Chin-Ya Huang <[email protected]>
Signed-off-by: Chin-Ya Huang <[email protected]>
@c3y1huang c3y1huang force-pushed the 8430-feat-v2-auto-salvage branch from 7468162 to 3d806c6 Compare November 6, 2024 04:34
Copy link
Member

@derekbit derekbit 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