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(v2): storage network with v2 data engine #3521

Merged
merged 3 commits into from
Feb 13, 2025

Conversation

c3y1huang
Copy link
Contributor

Which issue(s) this PR fixes:

Issue longhorn/longhorn#6450

What this PR does / why we need it:

Use storage network for V2 data engine.

Special notes for your reviewer:

None

Additional documentation or context

None

@c3y1huang c3y1huang self-assigned this Feb 3, 2025
Copy link

coderabbitai bot commented Feb 3, 2025

Walkthrough

This pull request modifies how storage IP addresses are handled during instance creation. In the engine controller, it adds logic to retrieve the instance manager pod and use its storage IP when setting the InitiatorAddress and TargetAddress for engine instances, along with enhanced error handling. The replica controller removes the assignment of the ImIP field. Additionally, the ImIP field is removed from both EngineInstanceCreateRequest and ReplicaInstanceCreateRequest in the engine API. Changes in the backing image controller improve the retrieval of the instance manager's storage IP.

Changes

File(s) Change Summary
controller/engine_controller.go Added logic to retrieve the instance manager pod via ec.ds.GetPod(im.Name); updated EngineInstanceCreateRequest to use the pod’s storage IP; enhanced error handling.
controller/replica_controller.go Removed the line that sets the ImIP field in the ReplicaInstanceCreateRequest.
engineapi/instance_manager.go Removed the ImIP field from both EngineInstanceCreateRequest and ReplicaInstanceCreateRequest structures.
controller/backing_image_controller.go Modified syncV2Copies method to retrieve storage IP from the instance manager pod instead of using its status IP; added error handling for pod retrieval.

Sequence Diagram(s)

Engine Instance Creation Flow

sequenceDiagram
    participant EC as EngineController
    participant DS as DataStore
    participant Pod as Instance Manager Pod
    participant ES as EngineService

    EC->>DS: GetPod(instanceManagerName)
    DS-->>EC: Pod (with storage IP)
    EC->>ES: CreateEngineInstance(InitiatorAddress & TargetAddress = storage IP)
    ES-->>EC: Instance process created
Loading

Replica Instance Creation Flow

sequenceDiagram
    participant RC as ReplicaController
    participant ES as EngineService

    RC->>ES: CreateReplicaInstance(without IM IP)
    ES-->>RC: Instance process created
Loading

Suggested reviewers

  • c3y1huang
  • ChanYiLin
  • innobead
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 6450-storage-network-support-v2 branch from 7bffa9e to f4b3312 Compare February 4, 2025 08:25
@c3y1huang
Copy link
Contributor Author

c3y1huang commented Feb 4, 2025

Test result:

  • -m v2_volume_test:
    > k -n longhorn-system get setting storage-network
    NAME              VALUE                          APPLIED   AGE
    storage-network   kube-system/demo-192-168-0-0   true      26h
    
    =========================== short test summary info ============================
    FAILED test_scheduling.py::test_data_locality_basic - AssertionError
    
    = 1 failed, 130 passed, 1 skipped, 258 deselected, 136 warnings in 24429.59s (6:47:09) =
    
    Known issue: [BUG] V2 volume fails to cleanup error replica and rebuild new one - test_data_locality_basic longhorn#10335
  • Backing image (manual):
    • create backing image with v2 data engine
    • create and attach volume with v2 data engine backing image

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

@derekbit derekbit force-pushed the 6450-storage-network-support-v2 branch 2 times, most recently from e3492b6 to d78b240 Compare February 6, 2025 04:16
derekbit
derekbit previously approved these changes Feb 6, 2025
@ChanYiLin
Copy link
Contributor

ChanYiLin commented Feb 6, 2025

Hi @c3y1huang
Could you please check if there is anything also needs to be changed for the v2 BackingImage?
V2 BackingImage is managed by instance-manager

There is only one place where it may need the instance-manager ip, not sure if in this case will we need to pass the storage network ip instead of pod ip.

  • longhorn-manager use engine proxy api to send request to instance manger to create the BackingImage in the spdk server
  • When syncing BackingImage between each instance-manager, e.g. from A to B
    • longhorn-manager get the srcInstanceManager.Status.IP of the copy A
    • _, err = engineClientProxy.SPDKBackingImageCreate(bi.Name, bi.Status.UUID, v2DiskUUID, bi.Status.Checksum, net.JoinHostPort(srcInstanceManager.Status.IP, strconv.Itoa(engineapi.InstanceManagerSpdkServiceDefaultPort)), sourceV2DiskUUID, bi.Name, uint64(bi.Status.Size))
    • the B instance-manager spdk server will use this ip address to get the client.NewSPDKClient(addr) to ask A to expose the spdk snapshot and connect it to get the device to do the copy.

@c3y1huang c3y1huang force-pushed the 6450-storage-network-support-v2 branch 2 times, most recently from 0c167dd to 7763b73 Compare February 10, 2025 05:41
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

🧹 Nitpick comments (1)
controller/backing_image_controller.go (1)

1647-1653: LGTM! Consider improving error messages.

The implementation correctly retrieves the storage IP from the instance manager pod. However, the error messages could be more descriptive.

Consider enhancing error messages to include more context:

-		return errors.Wrapf(err, "failed to get pod for instance manager %v", srcInstanceManager.Name)
+		return errors.Wrapf(err, "failed to get pod for source instance manager %v when syncing v2 backing image", srcInstanceManager.Name)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d78b240 and 7763b73.

📒 Files selected for processing (4)
  • controller/backing_image_controller.go (1 hunks)
  • controller/engine_controller.go (1 hunks)
  • controller/replica_controller.go (0 hunks)
  • engineapi/instance_manager.go (0 hunks)
💤 Files with no reviewable changes (2)
  • engineapi/instance_manager.go
  • controller/replica_controller.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • controller/engine_controller.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build binaries
  • GitHub Check: Summary
🔇 Additional comments (1)
controller/backing_image_controller.go (1)

1655-1655: LGTM! Storage IP integration looks good.

The code correctly uses the storage IP with proper host:port formatting for SPDK backing image creation.

@c3y1huang
Copy link
Contributor Author

Hi @c3y1huang Could you please check if there is anything also needs to be changed for the v2 BackingImage? V2 BackingImage is managed by instance-manager

There is only one place where it may need the instance-manager ip, not sure if in this case will we need to pass the storage network ip instead of pod ip.

  • longhorn-manager use engine proxy api to send request to instance manger to create the BackingImage in the spdk server

  • When syncing BackingImage between each instance-manager, e.g. from A to B

    • longhorn-manager get the srcInstanceManager.Status.IP of the copy A
    • _, err = engineClientProxy.SPDKBackingImageCreate(bi.Name, bi.Status.UUID, v2DiskUUID, bi.Status.Checksum, net.JoinHostPort(srcInstanceManager.Status.IP, strconv.Itoa(engineapi.InstanceManagerSpdkServiceDefaultPort)), sourceV2DiskUUID, bi.Name, uint64(bi.Status.Size))
    • the B instance-manager spdk server will use this ip address to get the client.NewSPDKClient(addr) to ask A to expose the spdk snapshot and connect it to get the device to do the copy.

Missed that. Thank you! I've updated it. PTAL.

@c3y1huang c3y1huang requested a review from derekbit February 10, 2025 06:00
@derekbit
Copy link
Member

LGTM. Need any updates for RWX volumes?

@c3y1huang
Copy link
Contributor Author

LGTM. Need any updates for RWX volumes?

I don't think so. We're using Kubernetes Endpoints for the RWX volumes. did I miss anything?
longhorn/longhorn#8184

@derekbit derekbit force-pushed the 6450-storage-network-support-v2 branch from 7763b73 to 0202a2c Compare February 11, 2025 13:54
@derekbit
Copy link
Member

derekbit commented Feb 11, 2025

LGTM. Need any updates for RWX volumes?

I don't think so. We're using Kubernetes Endpoints for the RWX volumes. did I miss anything? longhorn/longhorn#8184

No, just confirmed no things are missed. Thank you.

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-6450

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-6450

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
@derekbit derekbit force-pushed the 6450-storage-network-support-v2 branch from 0202a2c to 6fb5593 Compare February 13, 2025 07: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: 0

🔭 Outside diff range comments (1)
controller/engine_controller.go (1)

2087-2125: 💡 Verification agent

🧩 Analysis chain

Consider storage IP handling during engine upgrades.

The upgrade logic doesn't handle storage IP changes. This might cause issues during live upgrades if the storage network configuration changes.

Consider updating the upgrade logic to handle storage IP changes:

  1. Verify if storage IP changes during upgrade
  2. Update engine configuration if needed
  3. Document any limitations or requirements for storage network during upgrades

Run this script to check for potential upgrade issues:


🏁 Script executed:

#!/bin/bash
# Description: Check if there are any upgrade-related issues with storage IP

# Search for upgrade-related code that might need storage IP handling
rg -A 5 "UpgradeEngine|EngineUpgrade|ImageUpgrade" 

# Check for any existing upgrade tests
rg -A 5 "TestUpgrade|test.*upgrade"

Length of output: 26121


Action Required: Enhance Engine Upgrade Logic to Handle Storage IP Changes

The current upgrade process in controller/engine_controller.go (lines 2087–2125) does not account for potential storage IP changes. This omission may lead to issues during live upgrades if the storage network configuration is altered. To address this, please:

  • Detect Storage IP Changes: Incorporate logic to verify whether the storage IP has changed during an upgrade.
  • Update Engine Configuration: If a change is detected, update the engine configuration accordingly to prevent live replica disruption.
  • Documentation & Testing: Document any new limitations or requirements concerning storage IP handling during upgrades and consider adding tests to validate this scenario.
🧹 Nitpick comments (1)
controller/engine_controller.go (1)

485-491: Validate storage IP availability.

The code retrieves the storage IP but doesn't validate if it's available. Consider adding validation and a fallback mechanism.

Add validation before using the storage IP:

 instanceManagerPod, err := ec.ds.GetPod(im.Name)
 if err != nil {
     return nil, errors.Wrapf(err, "failed to get pod for instance manager %v", im.Name)
 }

 instanceManagerStorageIP := ec.ds.GetStorageIPFromPod(instanceManagerPod)
+if instanceManagerStorageIP == "" {
+    return nil, fmt.Errorf("storage IP not available for instance manager pod %v", im.Name)
+}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0202a2c and 6fb5593.

📒 Files selected for processing (4)
  • controller/backing_image_controller.go (1 hunks)
  • controller/engine_controller.go (1 hunks)
  • controller/replica_controller.go (0 hunks)
  • engineapi/instance_manager.go (0 hunks)
💤 Files with no reviewable changes (2)
  • engineapi/instance_manager.go
  • controller/replica_controller.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • controller/backing_image_controller.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build binaries
  • GitHub Check: Summary
🔇 Additional comments (1)
controller/engine_controller.go (1)

500-501: LGTM! Storage IP is consistently used.

The implementation correctly uses the storage IP for both initiator and target addresses, which aligns with the storage network requirements.

@mergify mergify bot merged commit c23fcec into longhorn:master Feb 13, 2025
7 of 8 checks passed
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