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(robot): uninstall when backing image exists #2240

Merged

Conversation

c3y1huang
Copy link
Collaborator

@c3y1huang c3y1huang commented Dec 31, 2024

Which issue(s) this PR fixes:

Issue longhorn/longhorn#10044

What this PR does / why we need it:

Adding a test for uninstalling Longhorn when there are backing images. This is for reproducing the issue described in longhorn/longhorn#10044. While the issue cannot be consistently reproduced, automating the test steps can help simplify the process.

Special notes for your reviewer:

None

Additional documentation or context

None

Summary by CodeRabbit

  • New Features

    • Enhanced backing image creation with support for data engine and minimum copy configurations.
    • Added new methods for managing backing image managers.
    • Introduced a new test case for uninstallation with existing backing images.
  • Bug Fixes

    • Improved error handling for backup store initialization when environment variables are not set.
  • Chores

    • Updated method signatures across multiple classes to support new backing image creation parameters.

@c3y1huang c3y1huang self-assigned this Dec 31, 2024
Copy link

coderabbitai bot commented Dec 31, 2024

Walkthrough

The pull request introduces modifications to the backing image management system across multiple files. The primary changes involve updating the create method signatures in various classes to include two new parameters: data_engine and min_copies. This modification affects the BackingImage, Base, CRD, and Rest classes in the backing image library. Additionally, a new test case is added to validate the uninstallation process when backing images exist, addressing potential issues with Longhorn uninstallation.

Changes

File Change Summary
e2e/libs/backing_image/backing_image.py - Added import for LonghornOperationStrategy
- Updated create method signature
- Modified backing_image instantiation in multiple methods
e2e/libs/backing_image/base.py - Updated create method signature to include data_engine and min_copies
e2e/libs/backing_image/crd.py - Updated create method signature to include data_engine and min_copies
e2e/libs/backing_image/rest.py - Updated create method signature
- Added new methods for backing image manager operations
e2e/libs/backupstore/base.py - Added conditional check in __init__ method for LONGHORN_BACKUPSTORE environment variable
e2e/libs/keywords/backing_image_keywords.py - Updated create_backing_image method signature with default values
e2e/tests/regression/test_backing_image.robot - Added new test case "Test Uninstall When Backing Image Exists"

Assessment against linked issues

Objective Addressed Explanation
Uninstallation failure with backing images [#10044]
Instance-manager pod stuck in terminating state Requires further verification in actual deployment

Possibly related PRs

Suggested reviewers

  • yangchiu
  • chriscchien

Poem

🐰 A Rabbit's Ode to Backing Images 🖼️
In the realm of bits and bytes so bright,
Backing images dance with delight,
New parameters, a graceful twirl,
Data engines and copies unfurl,
Code hops forward, clean and tight! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06bae72 and f8d2e4d.

📒 Files selected for processing (2)
  • e2e/libs/backing_image/base.py (1 hunks)
  • e2e/tests/regression/test_backing_image.robot (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • e2e/libs/backing_image/base.py
  • e2e/tests/regression/test_backing_image.robot
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: make check
  • GitHub Check: Summary

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.

CodeRabbit Configuration 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.

@c3y1huang c3y1huang force-pushed the 10044-backing-image-uninstall-failed branch 2 times, most recently from 4d63b50 to 06bae72 Compare January 9, 2025 23:45
@c3y1huang c3y1huang marked this pull request as ready for review January 9, 2025 23:45
@c3y1huang c3y1huang requested a review from a team as a code owner January 9, 2025 23:45
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: 2

🧹 Nitpick comments (3)
e2e/libs/backing_image/backing_image.py (1)

38-46: Refactor repeated CRD instantiation

Multiple methods are duplicating the CRD instantiation code. Consider refactoring this into a helper method or handling it in the constructor based on operation type.

Example refactor:

def _ensure_crd_backend(self):
    if not isinstance(self.backing_image, CRD):
        self.backing_image = CRD()

Then use it in methods:

def delete_backing_image_manager(self, name):
    self._ensure_crd_backend()
    return self.backing_image.delete_backing_image_manager(name)
e2e/tests/regression/test_backing_image.robot (2)

42-47: Document LOOP_COUNT and add verification steps

  1. The LOOP_COUNT variable should be documented
  2. Consider adding verification steps to ensure backing images are properly created before uninstalling:
    • Verify backing image status
    • Check min_copies requirement is met

Add verification steps:

        And Verify all disk file status of backing image v1-bi-qcow2 are ready
        And Verify all disk file status of backing image v1-bi-raw are ready
        And Verify all disk file status of backing image v2-bi-qcow2-1 are ready
        And Verify all disk file status of backing image v2-bi-raw-1 are ready

49-52: Add error handling verification

Consider adding steps to verify error handling during uninstallation:

  • Check for appropriate error messages
  • Verify cleanup of resources
        When Uninstall Longhorn
        Then Verify no error messages in logs
        And Check all resources are properly cleaned up
        And Check all Longhorn CRD removed
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd2fb66 and 06bae72.

📒 Files selected for processing (7)
  • e2e/libs/backing_image/backing_image.py (3 hunks)
  • e2e/libs/backing_image/base.py (1 hunks)
  • e2e/libs/backing_image/crd.py (1 hunks)
  • e2e/libs/backing_image/rest.py (4 hunks)
  • e2e/libs/backupstore/base.py (1 hunks)
  • e2e/libs/keywords/backing_image_keywords.py (1 hunks)
  • e2e/tests/regression/test_backing_image.robot (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (4)
e2e/libs/backing_image/crd.py (1)

17-17: Method signature needs implementation

The create method signature has been updated to include data_engine and min_copies parameters, but the method still returns NotImplemented. This method needs to be implemented to support the new test case for uninstalling Longhorn when backing images exist.

Would you like me to help implement this method based on the CRD schema?

e2e/libs/backing_image/rest.py (2)

Line range hint 15-25: LGTM! Proper implementation of the create method

The updated create method correctly uses the new parameters data_engine and min_copies in the backing image creation API call.


Line range hint 115-124: Implement backing image manager methods

These newly added methods are required for managing backing image managers but are currently unimplemented. They are essential for the test case that verifies uninstallation behavior with existing backing images.

Would you like me to help implement these methods? The implementation should mirror the functionality in the CRD class, using REST API calls instead of Kubernetes API.

e2e/libs/backupstore/base.py (1)

43-46: LGTM! Proper null check for backupstore configuration

Good defensive programming practice to handle the case when LONGHORN_BACKUPSTORE environment variable is not set. This prevents potential errors when backupstore configuration is not required for certain test scenarios.

e2e/libs/backing_image/base.py Outdated Show resolved Hide resolved
e2e/libs/keywords/backing_image_keywords.py Show resolved Hide resolved
longhorn/longhorn-10044

Signed-off-by: Chin-Ya Huang <[email protected]>
@c3y1huang c3y1huang force-pushed the 10044-backing-image-uninstall-failed branch from 06bae72 to f8d2e4d Compare January 9, 2025 23:52
Copy link
Member

@yangchiu yangchiu left a comment

Choose a reason for hiding this comment

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

LGTM

@yangchiu yangchiu merged commit 2f3e118 into longhorn:master Jan 13, 2025
5 of 7 checks passed
@c3y1huang c3y1huang deleted the 10044-backing-image-uninstall-failed branch January 14, 2025 04:02
@yangchiu
Copy link
Member

@mergify backport v1.8.x

Copy link

mergify bot commented Jan 15, 2025

backport v1.8.x

✅ Backports have been created

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