Skip to content

Conversation

@suleymanakbas91
Copy link

@suleymanakbas91 suleymanakbas91 commented Feb 9, 2026

Add environment variable support for configuring TopoLVM:

  • VG_NAME: LVM volume group name (default: myvg1)
  • SPARE_GB: Spare GB to reserve in volume group (default: 10)

This allows users to customize TopoLVM configuration without modifying source code, useful for testing environments where 10GB spare is too large.

Usage:
make run VG_NAME=testvg SPARE_GB=2 LVM_VOLSIZE=5G
VG_NAME=customvg SPARE_GB=5 sudo -E ./src/quickstart.sh

Closes #24

Summary by CodeRabbit

  • New Features

    • Storage is now configurable via environment variables (volume group name and spare GB) across tools, scripts, and container runtimes.
    • Runtime TopoLVM configuration and automated patching added so containerized components receive these settings.
  • Documentation

    • Expanded storage docs with a TopoLVM configuration section and examples for overriding VG_NAME and SPARE_GB.
  • Bug Fixes / Cleanup

    • Cleanup now removes TopoLVM artifacts and ensures services are reloaded during teardown.

Add environment variable support for configuring TopoLVM:
- VG_NAME: LVM volume group name (default: myvg1)
- SPARE_GB: Spare GB to reserve in volume group (default: 10)

This allows users to customize TopoLVM configuration without
modifying source code, useful for testing environments where
10GB spare is too large.

Usage:
  make run VG_NAME=testvg SPARE_GB=2 LVM_VOLSIZE=5G
  VG_NAME=customvg SPARE_GB=5 sudo -E ./src/quickstart.sh

Closes microshift-io#24

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@suleymanakbas91 suleymanakbas91 requested a review from a team as a code owner February 9, 2026 12:06
@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Adds VG_NAME and SPARE_GB configuration across packaging, orchestration, Makefile and Ansible defaults; replaces hard-coded VG references with variables; adds a runtime TopoLVM patch script and systemd ExecStartPre drop-in to generate an lvmd ConfigMap; propagates SPARE_GB into container and cleanup flows.

Changes

Cohort / File(s) Summary
GitHub Actions
​.github/actions/quick-rpm-clean/action.yaml, ​.github/actions/quick-start-clean/action.yaml
Replace hard-coded myvg1 with VG_NAME defaulting and use it for verification/removal; quick-rpm-clean copies patch script into container before running.
Documentation
CLAUDE.md
Document TopoLVM options: VG_NAME and SPARE_GB, with examples and updated env list.
Makefile / Build
Makefile
Add VG_NAME ?= myvg1 and SPARE_GB ?= 10; pass both into run/cluster-manager and related targets.
Ansible
ansible/roles/microshift-okd-bootc/tasks/topolvm.yaml, ansible/roles/microshift-okd-bootc/defaults/main.yaml, ansible/roles/microshift-okd-bootc/vars/main.yaml
Replace hard-coded myvg1 with lvm_vg_name variable, add lvm_spare_gb: 10 default, and remove the old literal var entry.
Container Packaging
packaging/bootc.Containerfile
Install src/topolvm/patch_lvmd_config.sh into image and add a systemd drop-in (ExecStartPre) to run the patch script before microshift starts.
Host tooling / orchestration
src/cluster_manager.sh, src/quickstart.sh, src/quickrpm.sh, src/quickclean.sh
Introduce SPARE_GB (default 10), make VG_NAME defaultable, propagate both into container envs; add setup_topolvm_config() in quickrpm to install drop-in and patch script; extend cleanup to remove TopoLVM artifacts and daemon-reload.
TopoLVM patch script
src/topolvm/patch_lvmd_config.sh
New script that reads VG_NAME and SPARE_GB (from /proc/1/environ), validates SPARE_GB, and writes topolvm lvmd ConfigMap + kustomization into /etc/microshift/manifests.d when non-defaults are provided.

Sequence Diagram(s)

sequenceDiagram
    participant Host as Host OS
    participant Systemd as systemd
    participant Patch as patch_lvmd_config.sh
    participant MicroShift as MicroShift Service/Container
    participant Manifests as /etc/microshift/manifests.d

    Host->>Host: Export VG_NAME, SPARE_GB
    Host->>Systemd: systemd start microshift.service
    Systemd->>Patch: ExecStartPre runs patch script
    Patch->>Patch: Read /proc/1/environ -> VG_NAME, SPARE_GB
    Patch->>Patch: Validate SPARE_GB
    Patch->>Manifests: Write topolvm-lvmd-configmap.yaml + kustomization (if non-default)
    Patch-->>Systemd: Exit success
    Systemd->>MicroShift: Start microshift container/service
    MicroShift->>Manifests: MicroShift loads generated manifests
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • eslutsky
  • agullon
  • pacevedom
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: making TopoLVM VG_NAME and SPARE_GB configurable, which aligns with the primary objectives.
Linked Issues check ✅ Passed The PR fully addresses issue #24 by making the hardcoded myvg1 value configurable through environment variables (VG_NAME and SPARE_GB) across all scripts and workflows.
Out of Scope Changes check ✅ Passed All changes are scoped to making VG_NAME and SPARE_GB configurable. Documentation updates (CLAUDE.md) and Ansible defaults support the main objective without introducing unrelated functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 Fix all issues with AI agents
In `@ansible/roles/microshift-okd-bootc/vars/main.yaml`:
- Around line 15-17: The variables lvm_vg_name and lvm_spare_gb are
self-referential and cause Ansible recursion; replace their template expressions
with plain literal defaults (e.g., set lvm_vg_name to "myvg1" and lvm_spare_gb
to 10) or move those literal defaults into defaults/main.yaml so they become
lowest-precedence defaults and can still be overridden by inventory or
--extra-vars; update any references to lvm_vg_name and lvm_spare_gb accordingly
and remove the "{{ ... | default(...) }}" constructs that reference the same
names.

In `@Makefile`:
- Line 27: VG_NAME is currently defined with := in the "Internal variables"
section so it can't be overridden from the environment; move the VG_NAME
definition into the "Options used in the 'run' target" section alongside
SPARE_GB and change its assignment to use ?= (e.g., VG_NAME ?= ...) so that
environment overrides like VG_NAME=testvg make run work; ensure you remove the
old := definition so there are no duplicate VG_NAME declarations and leave
SPARE_GB as-is.

In `@src/topolvm/patch_lvmd_config.sh`:
- Around line 23-26: The early-exit when VG_NAME=myvg1 and SPARE_GB=10 leaves
stale files in PATCH_DIR; modify the conditional branch in patch_lvmd_config.sh
so that before exiting it cleans PATCH_DIR (e.g., remove any existing patch
files or empty the directory) and handles the case where PATCH_DIR may not exist
or be empty; update the block that checks VG_NAME and SPARE_GB to perform the
cleanup of "${PATCH_DIR}" (or specific patch filenames) and then exit 0.
🧹 Nitpick comments (1)
src/topolvm/patch_lvmd_config.sh (1)

43-49: Consider validating SPARE_GB is numeric.

A non-numeric SPARE_GB value would produce an invalid lvmd.yaml, which could cause TopoLVM to fail at runtime with a confusing error.

Proposed validation (after line 19)
 SPARE_GB="${SPARE_GB:-10}"
+
+if ! [[ "${SPARE_GB}" =~ ^[0-9]+$ ]]; then
+    echo "ERROR: SPARE_GB must be a positive integer, got '${SPARE_GB}'" >&2
+    exit 1
+fi

- Fix Ansible self-referential variable recursion by moving
  lvm_vg_name and lvm_spare_gb defaults to defaults/main.yaml
- Move VG_NAME from internal variables to run options with ?=
  so environment overrides work correctly
- Clean up stale patch files when using default values

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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: 1

🤖 Fix all issues with AI agents
In `@src/topolvm/patch_lvmd_config.sh`:
- Around line 18-19: The script currently sets SPARE_GB but doesn't validate it;
add a guard after the SPARE_GB assignment that checks SPARE_GB matches a
non-negative integer (e.g. regex ^[0-9]+$ or numeric parse) and that it is >= 0,
and if not print a clear error referencing SPARE_GB (and exit with non-zero
status) so we fail fast before generating lvmd.yaml; keep the existing default
assignment (VG_NAME and SPARE_GB) but ensure the validation runs immediately
after the SPARE_GB variable is set.
🧹 Nitpick comments (2)
src/topolvm/patch_lvmd_config.sh (1)

33-52: YAML values should be quoted to be safe.

While LVM VG names are typically alphanumeric, quoting ${SPARE_GB} and ${VG_NAME} in the generated YAML guards against edge cases and makes the intent explicit.

Proposed fix
-        spare-gb: ${SPARE_GB}
-        volume-group: ${VG_NAME}
+        spare-gb: "${SPARE_GB}"
+        volume-group: "${VG_NAME}"
Makefile (1)

137-137: The env-var preamble is getting unwieldy.

Each target repeats 7+ variables inline. Consider defining a shared variable to reduce duplication and improve readability.

Example
+# Common environment for cluster_manager.sh invocations
+CLUSTER_ENV = USHIFT_IMAGE=${USHIFT_IMAGE} ISOLATED_NETWORK=${ISOLATED_NETWORK} \
+              LVM_DISK=${LVM_DISK} LVM_VOLSIZE=${LVM_VOLSIZE} \
+              VG_NAME=${VG_NAME} SPARE_GB=${SPARE_GB}
+
 .PHONY: run
 run:
-	`@USHIFT_IMAGE`=${USHIFT_IMAGE} ISOLATED_NETWORK=${ISOLATED_NETWORK} LVM_DISK=${LVM_DISK} LVM_VOLSIZE=${LVM_VOLSIZE} VG_NAME=${VG_NAME} SPARE_GB=${SPARE_GB} EXPOSE_KUBEAPI_PORT=${EXPOSE_KUBEAPI_PORT} ./src/cluster_manager.sh create
+	@${CLUSTER_ENV} EXPOSE_KUBEAPI_PORT=${EXPOSE_KUBEAPI_PORT} ./src/cluster_manager.sh create

Then reuse ${CLUSTER_ENV} in add-node, start, stop, run-ready, run-healthy, run-status, env, and clean.

suleymanakbas91 and others added 2 commits February 9, 2026 13:30
Validate that SPARE_GB is a non-negative integer before generating
the lvmd.yaml ConfigMap to fail fast with a clear error message.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The patch_lvmd_config.sh doesn't exist on main branch until the PR
is merged. Update quickrpm.sh to skip download if script already
exists, and update CI to pre-install the script from the PR branch.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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: 1

🤖 Fix all issues with AI agents
In @.github/actions/quick-rpm-clean/action.yaml:
- Around line 69-71: The run invoking quickrpm.sh forwards only TAG so VG_NAME
and SPARE_GB from the workflow environment are not available inside the
container; update the podman exec invocation that runs quickrpm.sh (the sudo
podman exec -i microshift-okd ... bash -xeuo pipefail < ./src/quickrpm.sh line)
to also pass VG_NAME and SPARE_GB into the container environment (e.g., add env
VG_NAME=... and env SPARE_GB=... tied to the workflow/workflow inputs) so
quickrpm.sh and the later verify step both see the same VG_NAME/SPARE_GB values.
🧹 Nitpick comments (3)
src/quickrpm.sh (2)

10-11: SPARE_GB is not validated before use.

If a user passes SPARE_GB="banana", the systemd drop-in is written and the error only surfaces at service start time (when patch_lvmd_config.sh validates). Consider failing fast here for a better user experience.

Suggested validation
 VG_NAME="${VG_NAME:-myvg1}"
 SPARE_GB="${SPARE_GB:-10}"
+
+if ! [[ "${SPARE_GB}" =~ ^[0-9]+$ ]]; then
+    echo "ERROR: SPARE_GB must be a non-negative integer, got '${SPARE_GB}'"
+    exit 1
+fi

121-125: Stale script on re-run with a different BRANCH.

The -x guard skips re-download, so switching BRANCH on a subsequent run won't update the patch script. Probably fine for a one-shot installer, but worth a comment if intentional.

.github/actions/quick-rpm-clean/action.yaml (1)

83-85: VG_NAME is read from the environment but not declared as an action input.

Other configurable values (bootc-image-url, install-tag, etc.) are declared in inputs:. Consider adding vg-name (and spare-gb) as optional inputs with defaults so callers can use the standard with: syntax and the interface is self-documenting.

Forward VG_NAME and SPARE_GB environment variables to the container
so quickrpm.sh and verify steps see consistent values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Make lvm volume group configurable

1 participant