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(robot): support multiple backup stores #2220

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

mantissahz
Copy link
Contributor

@mantissahz mantissahz commented Dec 23, 2024

Which issue(s) this PR fixes:

Issue # longhorn/longhorn#5411

What this PR does / why we need it:

Special notes for your reviewer:

Additional documentation or context

e2e test cases running: https://ci.longhorn.io/job/private/job/longhorn-e2e-test/2282

Summary by CodeRabbit

  • New Features

    • Enhanced backup verification and data integrity checks with updated keyword definitions.
    • Improved volume restoration operations by linking backups to their respective source volumes.
  • Bug Fixes

    • Added retry mechanisms for retrieving and deleting backup volumes to improve reliability.
  • Tests

    • Updated test cases for disaster recovery scenarios to clarify the source volume context.
    • Enhanced clarity in backup volume test cases by specifying the associated volumes.
    • Refined recurring job tests to improve reliability with added retry parameters.
  • Chores

    • Implemented cleanup procedures in test fixtures to maintain a clean testing environment.

fix test case `test_recurring_jobs_allow_detached_volume`

ref: longhorn/longhorn 5411

Signed-off-by: James Lu <[email protected]>
@mantissahz mantissahz self-assigned this Dec 23, 2024
@mantissahz mantissahz requested a review from a team as a code owner December 23, 2024 02:20
Copy link

coderabbitai bot commented Dec 23, 2024

Walkthrough

This pull request introduces comprehensive modifications to backup and volume management across multiple files. The changes primarily focus on enhancing backup verification and restoration processes by adding a new ${source_volume_id} parameter to various keywords and methods. These updates improve the specificity of backup operations, ensuring clearer tracking of volume-backup relationships. The modifications span test cases, resource files, and backend implementation, with a consistent approach to explicitly linking backups to their source volumes.

Changes

File Change Summary
e2e/keywords/backup.resource Updated Check volume keyword to include ${source_volume_id}
e2e/keywords/volume.resource Modified DR volume creation and restoration keywords to include source volume reference
e2e/libs/backup/rest.py Enhanced backup volume retrieval, deletion, and error handling methods
e2e/tests/negative/test_dr_volume_node_reboot.robot Updated test steps to explicitly reference source volumes
e2e/tests/regression/test_backup.robot Clarified backup volume references with source volume context
manager/integration/tests/backupstore.py Added backup_cleanup() call in fixture teardown
manager/integration/tests/test_recurring_job.py Added retry parameter to find_backup_volume function

Possibly related PRs

Suggested reviewers

  • yangchiu
  • chriscchien
  • derekbit

Poem

🐰 Backup Bunny's Ballad 🥕

In volumes deep and backups bright,
Source IDs now shine clear and tight.
Restoration's dance, a careful leap,
Where data's integrity we keep!
Hop along, our backup friend! 🚀


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.

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

🧹 Nitpick comments (3)
e2e/libs/backup/rest.py (2)

90-97: Consider raising an error when the backup volume is not found.
Currently, if the backup volume is not found, the function returns None. If the caller requires a valid backup volume for subsequent operations, raising an exception might make it easier to spot issues early and handle them more predictably.


207-208: Consider parallel or batched deletion for performance.
If there are many backup volumes, deleting them sequentially could become slow. You might consider parallel or batched deletions, but do ensure concurrency safety.

e2e/tests/negative/test_dr_volume_node_reboot.robot (1)

52-52: Maintain consistent terminology.
“Wait for volume 1 restoration from backup 0 of volume 0 completed” keeps the naming scheme consistent, reducing risk of test confusion.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8133437 and 287de91.

📒 Files selected for processing (7)
  • e2e/keywords/backup.resource (1 hunks)
  • e2e/keywords/volume.resource (2 hunks)
  • e2e/libs/backup/rest.py (3 hunks)
  • e2e/tests/negative/test_dr_volume_node_reboot.robot (2 hunks)
  • e2e/tests/regression/test_backup.robot (1 hunks)
  • manager/integration/tests/backupstore.py (1 hunks)
  • manager/integration/tests/test_recurring_job.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
e2e/libs/backup/rest.py

171-171: Comparison to None should be cond is not None

Replace with cond is not None

(E711)

🔇 Additional comments (18)
e2e/keywords/backup.resource (1)

43-46: Well-structured update to ensure uniqueness of backup references.
Adding “${source_volume_id}” clarifies the linkage between backup and its source volume. This prevents ambiguity when multiple volumes share similar naming patterns.

e2e/tests/negative/test_dr_volume_node_reboot.robot (6)

49-50: Improves clarity of DR volume creation flow.
Specifying “from backup 0 of volume 0” explicitly ties the DR volume to its source volume, eliminating confusion when multiple backups exist.


56-56: Verifying correct data source ensures robust DR testing.
The “Check volume 1 data is backup 0 of volume 0” step is an effective final data integrity check.


81-82: Retains clarity in incremental restoration references.
Adding “of volume 0” helps confirm that the DR volume references the correct source during restore.


85-85: Explicit reference for incremental restore consistency.
This step clarifies that the newly triggered incremental restore is from backup 1 of volume 0, aligning with test logic elsewhere.


87-87: Reinforce clarity of restoration process.
Referring to the specific source volume ensures that we track the correct restore event following node reboots.


91-91: Confirms final data correctness after incremental restore.
Verifying the DR volume truly matches “backup 1 of volume 0” strengthens confidence in incremental restoration logic.

e2e/tests/regression/test_backup.robot (6)

66-71: Good approach for initializing multiple DR volumes from the same backup.
Creating DR volumes 1, 2, and 3 all from “backup 0 of volume 0” ensures thorough coverage of parallel DR volume scenarios.


79-79: Efficient data validation step.
Ensuring the DR volume’s data matches the backup source after activation fosters robust incremental restore checks.


85-85: Incremental restore correctness.
Waiting for DR volume 2’s restoration from “backup 1 of volume 0” clarifies which volume/backup pair is being tested.


89-89: Validating data post-restore.
Executions of “Check volume 2 data is backup 1 of volume 0” confirm that the restore process remains consistent after new data is added.


94-94: Maintaining clarity for DR volume 3 restore.
Ensuring “Wait for volume 3 restoration from backup 2 of volume 0 completed” keeps consistent naming for incremental backup steps.


98-98: Ensures final incremental restore data integrity.
Verifying “Check volume 3 data is backup 2 of volume 0” completes the chain of incremental backups, guaranteeing correctness.

e2e/keywords/volume.resource (3)

19-24: LGTM: Well-structured enhancement for DR volume creation

The addition of source_volume_id parameter improves the traceability of backup sources, which is essential for supporting multiple backup stores. The implementation follows existing patterns for name generation and backup URL retrieval.


192-196: LGTM: Consistent enhancement for backup restoration tracking

The addition of source_volume_id parameter maintains consistency with the DR volume creation changes and properly tracks backup sources during restoration.


198-202: LGTM: Consistent enhancement for backup restoration initialization

The addition of source_volume_id parameter maintains consistency across the backup restoration workflow and properly tracks backup sources.

manager/integration/tests/backupstore.py (1)

83-83: LGTM: Enhanced test cleanup

Adding backup cleanup in the fixture teardown ensures proper cleanup of backup resources, preventing test interference and maintaining a clean test environment.

manager/integration/tests/test_recurring_job.py (1)

786-786: LGTM: Improved test reliability

Adding retry mechanism to find_backup_volume call improves test reliability by properly handling potential delays in backup volume availability.

e2e/libs/backup/rest.py Outdated Show resolved Hide resolved
Modify keywords of related resources to get backups with corresponding
volumes.

ref: longhorn/lonhorn 5411

Signed-off-by: James Lu <[email protected]>
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)
e2e/keywords/volume.resource (1)

19-23: LGTM! Consider adding documentation.

The changes correctly implement source volume tracking for DR volume creation. Consider adding a docstring to document the parameters and their purpose.

Add documentation like this:

 Create DR volume ${volume_id} from backup ${backup_id} of volume ${source_volume_id}
+    [Documentation]    Creates a DR volume from a backup
+    ...    ${volume_id} - The ID of the new DR volume
+    ...    ${backup_id} - The ID of the backup to restore from
+    ...    ${source_volume_id} - The ID of the volume that created the backup
     [Arguments]    &{config}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 287de91 and 9fde0e2.

📒 Files selected for processing (5)
  • e2e/keywords/backup.resource (1 hunks)
  • e2e/keywords/volume.resource (2 hunks)
  • e2e/libs/backup/rest.py (3 hunks)
  • e2e/tests/negative/test_dr_volume_node_reboot.robot (2 hunks)
  • e2e/tests/regression/test_backup.robot (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • e2e/tests/regression/test_backup.robot
  • e2e/keywords/backup.resource
  • e2e/tests/negative/test_dr_volume_node_reboot.robot
  • e2e/libs/backup/rest.py
🔇 Additional comments (2)
e2e/keywords/volume.resource (2)

192-195: LGTM! Changes maintain consistency with DR volume creation.

The addition of source_volume_id parameter correctly tracks the source volume during restoration completion checks.


198-201: LGTM! Changes maintain consistency across restoration keywords.

The addition of source_volume_id parameter correctly tracks the source volume during restoration start checks.

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 b80aa68 into longhorn:master Dec 23, 2024
9 checks passed
@yangchiu
Copy link
Member

@mergify backport v1.8.x

Copy link

mergify bot commented Dec 23, 2024

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.

2 participants