storage: preserve data when removing volumes - #204
Conversation
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 SummaryThe 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.
Confidence Score: 5/5The 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.
|
| 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
Reviews (1): Last reviewed commit: "storage: preserve data when removing vol..." | Re-trigger Greptile
What changed
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.