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

fix(upgrade): fix upgrade issues from v1.7.x to v1.8.0 #3383

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

derekbit
Copy link
Member

Which issue(s) this PR fixes:

Issue longhorn/longhorn#10032

What this PR does / why we need it:

Special notes for your reviewer:

Additional documentation or context

Longhorn 10032

Signed-off-by: Derek Su <derek.su@suse.com>
@derekbit derekbit requested a review from ChanYiLin December 22, 2024 09:21
@derekbit derekbit self-assigned this Dec 22, 2024
Copy link

coderabbitai bot commented Dec 22, 2024

Walkthrough

The changes in the upgrade.go file focus on enhancing the upgrade process from Longhorn version 1.7.x to 1.8.0. The modifications primarily involve improving error handling and resource management during the upgrade of various Longhorn resources such as volumes, backup volumes, backups, backup backing images, backing image data sources, and backing images. The updates ensure more robust handling of resource maps, setting default values, and managing resource states during the upgrade process.

Changes

File Change Summary
upgrade/v17xto180/upgrade.go - Updated UpgradeResources and UpgradeResourcesStatus function signatures
- Enhanced error handling in upgrade functions
- Improved logic for setting default backup target names
- Refined conditional checks for resource maps

Assessment against linked issues

Objective Addressed Explanation
Backup related test case failures [#10032] Unable to definitively confirm if the changes directly resolve the test failures without more context about the specific backup-related issues.

The changes appear to be related to the upgrade process, but the direct link to resolving the specific test failures in issue #10032 is not immediately clear from the provided code modifications. Further investigation and testing would be needed to confirm if these changes address the backup-related test case failures.


📜 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 e938d31 and 0f504fe.

📒 Files selected for processing (1)
  • upgrade/v17xto180/upgrade.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • upgrade/v17xto180/upgrade.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 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.

@derekbit
Copy link
Member Author

@mergify backport v1.8.x

Copy link

mergify bot commented Dec 22, 2024

backport v1.8.x

✅ Backports have been created

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)
upgrade/v17xto180/upgrade.go (1)

Line range hint 218-229: Consider extracting the DataEngine setting logic

Since both blocks perform similar operations on different maps, consider extracting this logic into a helper function to improve maintainability and reduce code duplication.

Here's a suggested implementation:

+func setDataEngineTypeForDiskFiles[T interface{ GetDataEngine() *longhorn.DataEngineType; SetDataEngine(t longhorn.DataEngineType) }](diskMap map[string]T) {
+    if diskMap != nil {
+        for diskUUID := range diskMap {
+            diskMap[diskUUID].SetDataEngine(longhorn.DataEngineTypeV1)
+        }
+    }
+}

 func upgradeBackingImages(namespace string, lhClient *lhclientset.Clientset, resourceMaps map[string]interface{}) (err error) {
     // ... existing code ...

     // before v1.8.0, there should not have any v2 data engine disk in the backing image.
-    if bi.Spec.DiskFileSpecMap != nil {
-        for diskUUID := range bi.Spec.DiskFileSpecMap {
-            bi.Spec.DiskFileSpecMap[diskUUID].DataEngine = longhorn.DataEngineTypeV1
-        }
-    }
+    setDataEngineTypeForDiskFiles(bi.Spec.DiskFileSpecMap)

     // before v1.8.0, there should not have any v2 data engine disk in the backing image.
-    if bi.Status.DiskFileStatusMap != nil {
-        for diskUUID := range bi.Status.DiskFileStatusMap {
-            bi.Status.DiskFileStatusMap[diskUUID].DataEngine = longhorn.DataEngineTypeV1
-        }
-    }
+    setDataEngineTypeForDiskFiles(bi.Status.DiskFileStatusMap)

     // ... rest of the code ...
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d87226 and e938d31.

📒 Files selected for processing (1)
  • upgrade/v17xto180/upgrade.go (1 hunks)
🧰 Additional context used
📓 Learnings (1)
upgrade/v17xto180/upgrade.go (2)
Learnt from: derekbit
PR: longhorn/longhorn-manager#3295
File: controller/backing_image_data_source_controller.go:404-407
Timestamp: 2024-12-13T07:06:57.033Z
Learning: In the `syncBackingImage` function in `controller/backing_image_data_source_controller.go`, when adding a new entry to `bi.Spec.DiskFileSpecMap`, the `DataEngine` is set to `DataEngineTypeV1` because the backing image data source always prepares the backing image on the v1 disk.
Learnt from: mantissahz
PR: longhorn/longhorn-manager#2182
File: upgrade/v17xto180/upgrade.go:52-58
Timestamp: 2024-11-10T16:45:04.898Z
Learning: In the `upgrade/v17xto180/upgrade.go` file, prefer to keep individual error handling in each resource upgrade function instead of consolidating them into a shared helper function.
🔇 Additional comments (2)
upgrade/v17xto180/upgrade.go (2)

218-222: LGTM: Setting DataEngine type for DiskFileSpecMap

The implementation correctly sets the DataEngine type to v1 for all disk files in the spec map, which aligns with the requirement that backing image data sources always prepare backing images on v1 disk.


Line range hint 225-229: LGTM: Setting DataEngine type for DiskFileStatusMap

The implementation maintains consistency by setting the DataEngine type to v1 in the status map, matching the spec map changes above.

Longhorn 10032

Signed-off-by: Derek Su <derek.su@suse.com>
@derekbit derekbit requested a review from mantissahz December 22, 2024 10:03
@derekbit
Copy link
Member Author

derekbit commented Dec 22, 2024

@mantissahz
Please remember to create volumes, backupVolumes, backupVolumes, backupTargets and releated resources and verify all required backupTargetName labels or spec files of the resources are correctly set after upgrade from v1.7.x to v1.8.0.

@mantissahz @ChanYiLin
Also create a ticket and a corresponding PR to update https://github.com/longhorn/longhorn-tests/blob/master/manager/integration/tests/test_upgrade.py#L219 for the labels and spec field validation.

cc @longhorn/qa @innobead

@derekbit derekbit changed the title fix(upgrade): fix stuck upgrade from v1.7.x to v1.8.0 fix(upgrade): fix upgrade issues from v1.7.x to v1.8.0 Dec 22, 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.

2 participants