Skip to content

[linstor] Make satellite plunger script continue on errors. - #728

Merged
Andrei Kvapil (kvaps) merged 1 commit into
cozystack:mainfrom
xy2:plunger-restarts
Mar 31, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
cozystack:mainfrom
xy2:plunger-restarts

Conversation

@xy2

@xy2 xy2 commented Mar 31, 2025 •

Copy link
Copy Markdown
Contributor

Do not restart the container if something goes wrong while plunger tries to fix the linstor state.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error notifications during system operations to ensure any issues are promptly reported.
  • Documentation
    • Updated descriptive information on secondary volume management to help clarify operational conditions.

@coderabbitai

coderabbitai Bot commented Mar 31, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request enhances the error handling within the plunger-satellite.sh script. It appends commands that detach stale loop devices and manage secondary DRBD volumes with error messages in case they fail. Additionally, comments have been updated to clarify the identification of secondary volumes based on the force-io-failure state, ensuring safe recreation of DRBD devices when they are not primary.

Changes

File Summary
packages/.../plunger-satellite.sh Added error handling to losetup --detach and drbdadm commands with `

Sequence Diagram(s)

sequenceDiagram
    participant Script as plunger-satellite.sh
    participant Command as Shell Command Executor

    Script->>Command: Execute `losetup --detach`
    Command-->>Script: Return Success/Failure
    alt Failure Detach
        Script->>Script: Output "Command failed"
    end

    Script->>Command: Execute `drbdadm down` for secondary volume
    Command-->>Script: Return Success/Failure
    alt Failure Down
        Script->>Script: Output "Command failed"
    end

    Script->>Command: Execute `drbdadm up` for secondary volume
    Command-->>Script: Return Success/Failure
    alt Failure Up
        Script->>Script: Output "Command failed"
    end
Loading

Possibly related PRs

Suggested reviewers

  • lllamnyp
  • kvaps

Poem

A hop in the code, swift and neat,
Errors now caught with a rhythmic beat.
Loop devices and volumes now sing,
"Command failed" echoes, a small win we bring.
From a rabbit’s heart, cheers resound so sweet!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (2)
packages/system/linstor/hack/plunger/plunger-satellite.sh (2)

29-29: Enhance Error Message for Losetup Detachment
The error-handling in line 29 now prevents the script from exiting on a failed detach operation. However, the generic message "Command failed" makes it harder to identify which command failed during execution. Consider including the command name and the failing device to improve clarity. Additionally, writing the error to stderr can help separate it from normal output.

Suggested diff:

-    /usr/sbin/losetup --detach "${stale_device}" || echo "Command failed"
+    /usr/sbin/losetup --detach "${stale_device}" || echo "losetup failed to detach ${stale_device}" >&2

39-40: Improve Error Messaging for DRBDADM Commands
Similar to the previous comment, the error messages for the drbdadm down and drbdadm up commands (lines 39–40) would benefit from being more descriptive. Explicit messages that include the secondary volume identifier will simplify troubleshooting. Redirecting these error messages to stderr is also recommended.

Suggested diff:

-    drbdadm down "${secondary}" || echo "Command failed"
+    drbdadm down "${secondary}" || echo "drbdadm down command failed for ${secondary}" >&2
-    drbdadm up "${secondary}" || echo "Command failed"
+    drbdadm up "${secondary}" || echo "drbdadm up command failed for ${secondary}" >&2
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 59aac50 and 0292f70.

📒 Files selected for processing (1)
  • packages/system/linstor/hack/plunger/plunger-satellite.sh (1 hunks)
🔇 Additional comments (1)
packages/system/linstor/hack/plunger/plunger-satellite.sh (1)

32-34: Clarify Comments for Secondary Volume Handling
The added comments (lines 32–34) provide clearer context on why secondary volumes with forced I/O failures are being detected and safely recreated. This added documentation increases maintainability and helps any future developer understand the rationale behind this block.

@kvaps Andrei Kvapil (kvaps) Mar 31, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

xy2 what do you think to just remove set -e from the script, instead of explicitly specifying this for every command?

@kvaps Andrei Kvapil (kvaps) changed the title Make satellite plunger script continue on errors. [linstor] Make satellite plunger script continue on errors. Mar 31, 2025

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@kvaps
Andrei Kvapil (kvaps) merged commit bdc3525 into cozystack:main Mar 31, 2025
@xy2
xy2 deleted the plunger-restarts branch April 10, 2025 02:23
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