Skip to content

storage: preserve data when removing volumes - #204

Merged
Zariel merged 1 commit into
mainfrom
agent/storage-removal-semantics
Aug 5, 2026
Merged

storage: preserve data when removing volumes#204
Zariel merged 1 commit into
mainfrom
agent/storage-removal-semantics

Conversation

@Zariel

@Zariel Zariel commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • explicitly stop managed mount units for removal-only storage changes
  • return before discovery, repartitioning, formatting, or wiping
  • document and expose the non-destructive removal contract in config diff
  • cover add, live removal, preserved filesystem, and safe re-add in the installed-runtime journey

Why

Removal-only changes produced stop targets but returned early when there were no replacement volumes, so a successful online apply could leave the old filesystem mounted until reboot.

Treat volume removal as an explicit unmount and management stop without
rediscovery or destructive device operations. Document the contract and
cover it through config diff, unit tests, installed-runtime VM testing,
and the public add/remove/re-add journey.
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown

Greptile Summary

The PR makes removal-only storage applies explicitly stop managed mount units while bypassing discovery and all storage-mutating preparation. It also documents the preservation contract and extends installed-runtime coverage through add, remove, and re-add.

  • Stops removed or replaced volume mount units even when no desired volumes require preparation.
  • Returns before discovery, repartitioning, formatting, or wiping for removal-only changes.
  • Reports non-destructive removal semantics through config diff output and documentation.
  • Adds VM disk identity plumbing and an end-to-end preservation journey.

Confidence Score: 5/5

The PR appears safe to merge, with the removal-only path stopping the managed mount and returning before any destructive storage operation.

The changed control flow handles removal-only configurations without discovery or preparation, while replacement and addition paths retain their preflight and acknowledgement checks; the expanded runtime journey verifies that the filesystem and marker data survive removal and re-add.

Important Files Changed

Filename Overview
internal/katlc/agent/volume_apply.go Corrects the removal-only early return so managed mounts are stopped before exiting without storage discovery or mutation.
internal/installer/configbundle/inspect.go Gives removed storage entries a precise non-destructive lifecycle message while retaining existing classification behavior.
internal/vmtest/config_apply_smoke_test.go Extends the installed-runtime journey to verify live add, unmount and unit removal, filesystem preservation, and successful re-add.
internal/vmtest/installed_node.go Assigns the installed runtime’s boot image a stable root serial so added data disks can be selected independently.
internal/vmtest/libvirt_vm.go Makes the boot-image serial configurable while preserving the existing default for other VM paths.

Sequence Diagram

sequenceDiagram
    participant Operator
    participant Agent
    participant Systemd
    participant Storage
    Operator->>Agent: Apply removal-only configuration
    Agent->>Systemd: Stop managed volume mount unit
    Systemd-->>Agent: Volume unmounted
    Note over Agent,Storage: Skip discovery, planning, repartitioning, formatting, and wiping
    Agent-->>Operator: Apply succeeds
    Operator->>Agent: Re-add matching filesystem selector
    Agent->>Storage: Discover preserved filesystem
    Agent->>Systemd: Activate generated mount unit
    Systemd-->>Operator: Preserved data is mounted again
Loading

Reviews (1): Last reviewed commit: "storage: preserve data when removing vol..." | Re-trigger Greptile

@Zariel
Zariel merged commit 2655e27 into main Aug 5, 2026
6 checks passed
@Zariel
Zariel deleted the agent/storage-removal-semantics branch August 5, 2026 22:34
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.

1 participant