Skip to content

Add missing permissions to the Linstor plunger. - #693

Merged
Andrei Kvapil (kvaps) merged 1 commit into
cozystack:mainfrom
xy2:209-plunger-permissions
Mar 12, 2025
Merged

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

Conversation

@xy2

@xy2 xy2 commented Mar 12, 2025 •

Copy link
Copy Markdown
Contributor

The Linstor satellite creates problems with admin privileges, so the plunger needs the same privileges to fix those problems.

Also, use the native losetup. The Linstor image has a wrapper with an additional function that we do not need here.

Summary by CodeRabbit

  • Refactor

    • Improved the management of unused loop devices with clearer feedback and refined error handling.
  • New Features

    • Enhanced container configuration by adding elevated system permissions, allowing the container to perform higher-level operations.

@coderabbitai

coderabbitai Bot commented Mar 12, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request modifies two files. The first file updates the logic in a shell script to detect and detach orphaned loop devices by storing output in a variable and iterating over each device, with added echo feedback and suppressed error messages. The second file alters a container configuration by adding additional capabilities and enabling privileged mode.

Changes

File Summary
packages/.../plunger-satellite.sh Replaces a single pipeline for loop device detection with a variable and loop; detaches each device individually with echo feedback; suppresses some error output.
packages/.../satellites-plunger.yaml Adds NET_ADMIN and SYS_ADMIN capabilities to the container and sets privileged: true, while retaining existing drop capabilities.

Sequence Diagram(s)

sequenceDiagram
    participant Script as plunger-satellite.sh
    participant Losetup as losetup
    participant Device as Loop Device
    Script->>Losetup: Execute 'losetup' to list devices
    Losetup-->>Script: Return list of loopback devices
    Script->>Script: Store list in 'stale_loopbacks'
    loop For each stale device
        Script->>Losetup: Detach device (losetup -d)
        Losetup-->>Script: Detachment confirmation (errors suppressed)
        Script->>Script: Echo feedback message
    end
Loading

Poem

I'm a rabbit hopping through new code trails,
Loop devices now unchained as each one fails.
With echo hops and quiet errors in view,
The script prances on, fresh and anew.
A bouncy change awaits; carrots and code prevail!
🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

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

24-30: Direct usage of native losetup for loop device management.
The revised block leverages /usr/sbin/losetup --json combined with jq to filter and identify stale loop devices, bypassing the redundant wrapper. This clarifies the logic and supports robust error handling. Consider adding safeguards or logging in case the JSON structure provided by losetup changes in the future.


28-28: Debug tracing enabled within loop.
Using set -x here aids in debugging by echoing the detachment command. If verbose output is a concern in a production environment, you might consider disabling the tracing with set +x immediately after the command.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e10f95 and 521a57c.

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

19-21: Enhanced container capabilities added.
The addition of NET_ADMIN and SYS_ADMIN in the capabilities list directly addresses the permission issues described in the PR objectives. This change enables the plunger container to perform low-level network and system operations as required.


24-24: Privileged mode enabled.
Setting privileged: true ensures the container gains the necessary elevated privileges to operate correctly alongside the satellite, which helps overcome the discrepancies in admin privileges.

packages/system/linstor/hack/plunger/plunger-satellite.sh (1)

33-39: Robust reconnection logic for disconnected secondary volumes.
The modified block detects DRBD secondary volumes that have lost connection by parsing drbdadm status with awk and re-establishes their connection. This approach enhances reliability, assuming the regex correctly identifies all relevant secondaries.

@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 423514b into cozystack:main Mar 12, 2025
@xy2
xy2 deleted the 209-plunger-permissions branch March 12, 2025 21:08
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