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

Allow overriding sysctl parameters via /etc/sysctl.d files #3883

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

sairon
Copy link
Member

@sairon sairon commented Feb 19, 2025

Relocate current content of /etc/sysctl.d to /usr/lib and make the /etc folder writable via a bind mount.

Summary by CodeRabbit

  • New Features
    • Introduced a new configuration setup that ensures the kernel's persistent system settings are reliably applied during system startup. This enhancement helps maintain consistent system behavior by correctly managing the sequence of configuration application.

Relocate current content of /etc/sysctl.d to /usr/lib and make the /etc folder
writable via a bind mount.
@sairon sairon added the os label Feb 19, 2025
@sairon sairon requested a review from agners February 19, 2025 14:13
@sairon
Copy link
Member Author

sairon commented Feb 19, 2025

One of the use cases can also be configuration of swappiness discussed in #968 (via /etc/sysctl.d/15-vm.conf).

Copy link

coderabbitai bot commented Feb 19, 2025

📝 Walkthrough

Walkthrough

A new systemd mount unit file named etc-sysctl.d.mount has been added. This unit defines a bind mount configuration that mounts /mnt/overlay/etc/sysctl.d to /etc/sysctl.d. It specifies that the mount unit must start after mnt-overlay.mount and before systemd-sysctl.service, and it is enabled through the hassos-bind.target.

Changes

File(s) Change Summary
buildroot-external/.../etc-sysctl.d.mount Added a new systemd mount unit file that binds /mnt/overlay/etc/sysctl.d to /etc/sysctl.d. Specifies ordering dependencies: after mnt-overlay.mount and before systemd-sysctl.service; enabled by hassos-bind.target.

Sequence Diagram(s)

sequenceDiagram
    participant Target as hassos-bind.target
    participant MntOverlay as mnt-overlay.mount
    participant SysctlMount as etc-sysctl.d.mount
    participant SysctlService as systemd-sysctl.service

    Target->>MntOverlay: Trigger mount initialization
    MntOverlay->>SysctlMount: Enable dependent mount (After condition)
    SysctlMount->>SysctlService: Ensure mount is active (Before condition)
Loading

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 or @coderabbitai title 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: 0

🧹 Nitpick comments (1)
buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-sysctl.d.mount (1)

1-15: Consider documenting the security implications.

While the implementation is correct, it would be helpful to document:

  1. The security implications of allowing sysctl parameter overrides
  2. Any validation or restrictions on the parameters that can be overridden
  3. Usage guidelines for system administrators

Would you like me to help draft documentation covering these aspects?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc7b693 and 866b33b.

📒 Files selected for processing (1)
  • buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-sysctl.d.mount (1 hunks)
🔇 Additional comments (3)
buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-sysctl.d.mount (3)

1-6: LGTM! Unit dependencies and ordering are correctly defined.

The unit section properly ensures that:

  • The mount happens after the overlay mount is ready
  • The mount is complete before systemd-sysctl.service starts reading parameters

13-14: LGTM! Proper integration with hassos-bind.target.

The mount unit is correctly integrated with hassos-bind.target, ensuring it's activated at the appropriate time during system initialization.


7-12:

❓ Verification inconclusive

Verify the mount configuration and directory existence.

The mount configuration looks correct for a bind mount. However, we should verify that:

  1. The source directory exists or is created during system initialization
  2. The target directory exists or is created during system initialization

🏁 Script executed:

#!/bin/bash
# Description: Check if the source and target directories are properly set up in the system

# Check if the source directory exists in the rootfs overlay
echo "Checking source directory in rootfs overlay..."
fd "sysctl.d$" buildroot-external/rootfs-overlay/

# Check if there are any references to creating these directories in build scripts
echo "Checking for directory creation in scripts..."
rg -A 2 "mkdir.*sysctl\.d"

Length of output: 384


Action: Reassess the Bind Mount Source Directory for /mnt/overlay/etc/sysctl.d

The bind mount unit in
buildroot-external/rootfs-overlay/usr/lib/systemd/system/etc-sysctl.d.mount
appears syntactically correct. However, during verification we observed:

  • The mount unit specifies What=/mnt/overlay/etc/sysctl.d, but a search of the overlay revealed directories at:

    • buildroot-external/rootfs-overlay/etc/sysctl.d/
    • buildroot-external/rootfs-overlay/usr/lib/sysctl.d/

    There was no evidence of a directory matching /mnt/overlay/etc/sysctl.d, which raises a question about whether the intended source directory actually exists in the final system image.

  • The absence of any build-script references (e.g., via mkdir) for creating a /mnt/overlay/etc/sysctl.d suggests that this directory might neither be present by default nor generated during initialization.

Please verify that:

  • The source directory (What=/mnt/overlay/etc/sysctl.d) is either provided by the overlay or is created at runtime.
  • The target directory (Where=/etc/sysctl.d) is available as expected.

Manual confirmation is recommended to ensure that the paths in the mount unit align with the actual directory structure in the built system.

@sairon sairon merged commit 1b51199 into dev Feb 19, 2025
3 checks passed
@sairon sairon deleted the persistent-sysctl-d branch February 19, 2025 14:33
sairon added a commit that referenced this pull request Feb 19, 2025
After relocation of kernel parameters in #3883, move swappiness parameter to
file that overrides only this value. This is to potentially avoid the risk of
losing other parameters that could be added there when the file is overridden
in /etc/sysctl.d (either manually or using future os-agent interface).

Refs #968
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