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(configmap): remove data of Configmap after test #2272

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

mantissahz
Copy link
Contributor

@mantissahz mantissahz commented Jan 15, 2025

Which issue(s) this PR fixes:

Issue # longhorn/longhorn#10213

What this PR does / why we need it:

The config map longhorn-default-resource is reset
with data of backup-target, backup-target-credential-secret,
and backupstore-poll-interval but they should be removed, not reset.

Special notes for your reviewer:

Additional documentation or context

Summary by CodeRabbit

  • Tests
    • Enhanced backup cleanup process with retry mechanism to ensure complete backup deletion
    • Updated test settings import statements for better clarity
    • Improved configuration management for default settings in Longhorn system

when backup-related test case is finished

ref: longhorn/longhorn 10213

Signed-off-by: James Lu <[email protected]>
The config map `longhorn-default-resource` is reset
with data of `backup-target`, `backup-target-credential-secret`,
and `backupstore-poll-interval` but they should be removed, not
reset.

ref: longhorn/longhorn 10213

Signed-off-by: James Lu <[email protected]>
@mantissahz mantissahz self-assigned this Jan 15, 2025
@mantissahz mantissahz requested a review from a team as a code owner January 15, 2025 06:50
Copy link

coderabbitai bot commented Jan 15, 2025

Walkthrough

The pull request introduces enhancements to backup management in the Longhorn system. In the backupstore.py file, a new retry mechanism is added to the backup_cleanup function to ensure thorough backup deletion. The test_settings.py file receives updates to import statements and configuration management, specifically improving how default settings are reset and handled for backup store configurations.

Changes

File Change Summary
manager/integration/tests/backupstore.py Added retry logic in backup_cleanup function to ensure complete backup deletion
manager/integration/tests/test_settings.py - Expanded import statements from backupstore module
- Modified update_settings_via_configmap to use init_longhorn_default_setting_configmap
- Updated reset_default_settings function for more structured config map management

Sequence Diagram

sequenceDiagram
    participant Backup Cleanup Function
    participant API
    Backup Cleanup Function->>API: Query existing backups
    alt Backups exist
        Backup Cleanup Function->>Backup Cleanup Function: Wait and retry
        Backup Cleanup Function->>API: Recheck backup list
    end
    Backup Cleanup Function->>API: Confirm no backups remain
Loading

Possibly related PRs

Suggested reviewers

  • COLDTURNIP
  • derekbit
  • chriscchien
  • yangchiu
  • roger-ryao

Poem

🐰 Backups dancing, then they flee
Retry magic sets them free
Config maps reset with care
Longhorn's cleanup beyond compare
Robust testing, rabbit's delight! 🧹✨


📜 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 2f3e118 and 986fee5.

📒 Files selected for processing (2)
  • manager/integration/tests/backupstore.py (1 hunks)
  • manager/integration/tests/test_settings.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: flake8 check
  • GitHub Check: Summary
🔇 Additional comments (3)
manager/integration/tests/backupstore.py (1)

362-376: LGTM! Robust retry mechanism for backup cleanup.

The added retry mechanism ensures thorough backup deletion by checking the API multiple times. The error message in the assertion provides good debugging context by showing any remaining backups.

Let's verify the retry constants are appropriate:

✅ Verification successful

Retry constants are well-tuned for backup cleanup verification

The code uses appropriate retry settings from common.py:

  • 30 retries with 1-second intervals
  • Maximum wait time of 30 seconds is sufficient for backup cleanup
  • Frequent checks enable quick verification while being mindful of API load
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check retry constant definitions
rg "RETRY_COUNTS_SHORT.*=|RETRY_INTERVAL.*=" 

Length of output: 1424

manager/integration/tests/test_settings.py (2)

51-57: LGTM! Clean import organization.

The imports are well organized and properly grouped, bringing in the necessary backup-related functions and constants.


1127-1144: LGTM! Proper cleanup of configmap data.

The code properly handles cleanup for both configmap types and ensures backup settings are reset, aligning with the PR objective to remove configmap data after tests.

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.

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

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 b3480ad into longhorn:master Jan 15, 2025
9 checks passed
@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