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: add update backup target action #830

Merged
merged 5 commits into from
Dec 23, 2024

Conversation

a110605
Copy link
Contributor

@a110605 a110605 commented Dec 19, 2024

What this PR does / why we need it

Issue

longhorn/longhorn#8647

Test Result

LONGHORN_MANAGER_IP=http://152.42.233.250:30001/ npm run dev

Update volume backup target

volume_update.mov

Bulk update backup target

bulk_update.mov

Fix action in backup detail page

Screenshot 2024-12-19 at 10 49 48 AM

Additional documentation or context

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced modals for updating backup targets, enhancing user interaction for both single and bulk updates.
    • Improved backup filtering and error handling for better user feedback.
    • Added functionality for managing backup target updates in the volume management workflow.
  • Bug Fixes

    • Enhanced the logic for identifying current backups based on query parameters.
  • Refactor

    • Streamlined method names for consistency and clarity.
    • Updated state management for volume operations to improve user experience.
  • Chores

    • Updated prop types and method signatures to reflect new functionalities.

@a110605 a110605 self-assigned this Dec 19, 2024
Copy link

coderabbitai bot commented Dec 19, 2024

Walkthrough

The pull request introduces comprehensive enhancements to backup and volume management functionality across multiple files. The changes focus on improving backup target updates, introducing new modal components for managing backup targets, and refactoring existing code to support more flexible keyword-based filtering. The modifications span several components and utility functions, enabling more granular control over backup volume operations and providing a more intuitive user interface for managing backup targets.

Changes

File Change Summary
src/models/backup.js - Updated updateBackgroundBackups reducer to filter backup data using search keyword
- Enhanced queryBackupTarget effect with improved error message handling
- Streamlined syncAllBackupVolumes effect
- Updated method signatures for CreateStandVolume and BulkCreateStandVolume to capitalize names
src/models/volume.js - Added new modal visibility states for backup target updates
- Introduced new effects and reducers for managing backup target modals
- Added state properties and methods for backup target updates
src/routes/backup/BackupDetail.js - Modified to identify current backup using keyword instead of volume name
- Adjusted filtering and payloads for backup operations
src/routes/backup/BackupVolume.js - Renamed DeleteAllBackups to deleteAllBackups and refactored method implementation
src/routes/backup/BackupVolumeList.js - Changed DeleteAllBackups prop to deleteAllBackups for consistency
src/routes/volume/UpdateBackupTargetModal.js - New modal component for updating individual backup targets
src/routes/volume/UpdateBulkBackupTargetModal.js - New modal component for bulk updating backup targets
src/routes/volume/VolumeActions.js - Added support for updating backup target actions
src/routes/volume/VolumeBulkActions.js - Added support for bulk updating backup target actions
src/routes/volume/VolumeList.js - Added prop for handling backup target updates
src/utils/store.js - Modified getBackupVolumeName to return search.keyword
src/utils/dataDependency.js - Updated httpDataDependency for /backingImage to include new dependency

Sequence Diagram

sequenceDiagram
    participant User
    participant VolumeList
    participant UpdateBackupTargetModal
    participant VolumeModel
    
    User->>VolumeList: Select Update Backup Target
    VolumeList->>UpdateBackupTargetModal: Show Modal
    User->>UpdateBackupTargetModal: Select New Backup Target
    UpdateBackupTargetModal->>VolumeModel: Dispatch Update Action
    VolumeModel-->>UpdateBackupTargetModal: Confirm Update
    UpdateBackupTargetModal-->>VolumeList: Close Modal
Loading

Poem

🐰 Backup Bunnies' Ballad 🔧

In volumes of data, we hop and we dance,
Updating targets with algorithmic prance,
Modals that sparkle, keywords so bright,
Our backup ballet takes magical flight!

Whiskers of code, twitching with glee 🐾

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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

@a110605 a110605 changed the title Backup target 2 Add update backup target action Dec 19, 2024
@a110605 a110605 changed the title Add update backup target action feat: add update backup target action Dec 19, 2024
@a110605 a110605 requested a review from derekbit December 19, 2024 07:55
coderabbitai[bot]

This comment was marked as spam.

const v1DataEngineEnabledSetting = settings.find(s => s.id === 'v1-data-engine')
const v2DataEngineEnabledSetting = settings.find(s => s.id === 'v2-data-engine')
const v1DataEngineEnabled = v1DataEngineEnabledSetting?.value === 'true'
const v2DataEngineEnabled = v2DataEngineEnabledSetting?.value === 'true'

const backups = volumeName ? backupData.filter(bk => bk.volumeName === volumeName) : backupData
sortBackups(backupData)
const backups = currentBackUp ? backupData.filter(bk => bk.volumeName === currentBackUp.volumeName) : backupData
Copy link
Contributor

Choose a reason for hiding this comment

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

We might need to add the backuptarget filter to the URL as well?
The scenarios are as follows:

  • Create a volume with the backup target default and create a backup. (e.g. 1217-test)
  • Change the backup target to cifs and create another backup.
  • On the backup page, both backups appear with their respective targets (expected).
    Screenshot 2024-12-20 at 10 40 38 AM (2)
  • Clicking the volume with the default target shows cifs in the details page.
    Screenshot 2024-12-20 at 10 43 11 AM (2)

Copy link
Contributor

@houhoucoop houhoucoop Dec 20, 2024

Choose a reason for hiding this comment

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

Another issue found: When clicking Restore Latest Backup and Create Disaster Recovery Volume for 1217-test (backup target: default), the modal doesn’t appear.

Copy link
Contributor Author

@a110605 a110605 Dec 20, 2024

Choose a reason for hiding this comment

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

Like the backend bug that the /v1/backupvolumes/bug-test-a98258ed?action=backupList (default) returns cifs backup data. @mantissahz will fix from backend first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@houhoucoop , @mantissahz , let's review and merge this PR to add update backup target feature first. We can fix this bug in next PR working with backend change.

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)
src/utils/dataDependency.js (1)

188-188: Consider performance implications of additional dependency

Adding the 'backup' dependency means that backup-related data will be queried whenever the backing image route is accessed. This could impact performance if the backup data is large and not immediately needed.

Consider:

  1. Lazy loading the backup data only when needed
  2. Adding comments explaining why this dependency is necessary
  3. Documenting any performance impact in the PR description
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 48c0f2c and d68cc66.

📒 Files selected for processing (1)
  • src/utils/dataDependency.js (1 hunks)
🔇 Additional comments (1)
src/utils/dataDependency.js (1)

188-188: Verify the backup dependency usage for backing images

The addition of 'backup' dependency for '/backingImage' path looks correct, but let's verify that this dependency is actually needed and used in the backing image components.

Let's check the usage:

✅ Verification successful

The backup dependency for backing images is correctly required

The verification shows that the backup dependency is actively used in the backing image components:

  • BackupBackingImage.js handles backup-related operations and UI for backing images
  • CreateBackupBackingImageModal.js manages backup target selection and backup creation
  • Multiple components interact with backup-related data, including backup targets, backup operations, and backup states

The dependency addition is necessary to ensure proper data availability for these backup-related features in the backing image section.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if backing image components use backup-related data

# Search for backup-related data usage in backing image components
echo "Checking backup data usage in backing image components..."
rg -l 'backup' --type js src/routes/backingImage/

# Check if the backing image components dispatch any backup-related actions
echo "Checking backup action dispatches..."
ast-grep --pattern 'dispatch({
  type: $_, 
  payload: {
    backup: $_
  }
})' src/routes/backingImage/

Length of output: 939


Script:

#!/bin/bash
# Let's check the actual usage of backup data in these files
echo "Checking BackupBackingImage.js for backup data usage..."
rg -A 5 'backup' src/routes/backingImage/BackupBackingImage.js

echo "\nChecking CreateBackupBackingImageModal.js..."
rg -A 5 'backup' src/routes/backingImage/CreateBackupBackingImageModal.js

echo "\nChecking RestoreBackupBackingImageModal.js..."
rg -A 5 'backup' src/routes/backingImage/RestoreBackupBackingImageModal.js

# Check if there are any direct references to backup store/state
echo "\nChecking for backup store/state usage..."
ast-grep --pattern 'backup: state.backup' src/routes/backingImage/

Length of output: 4095

coderabbitai[bot]

This comment was marked as spam.

Copy link
Contributor

@houhoucoop houhoucoop left a comment

Choose a reason for hiding this comment

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

LGTM

@a110605 a110605 merged commit ddfa9dd into longhorn:master Dec 23, 2024
7 checks passed
@a110605
Copy link
Contributor Author

a110605 commented Dec 23, 2024

@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants