Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion internal/controllers/vgmanager/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,25 @@ func (r *Reconciler) deleteRemovedDevices(
devicesToRemove := make([]string, 0)

for _, pv := range currentVG.PVs {
if !slices.Contains(userProvidedMappings, pv.PvName) {
// Check if the PV matches any user-provided path
// We need to handle symlinks: the PV might be stored as /dev/mapper/encrypted
// while the user path resolves to /dev/dm-0, or vice versa
pvMatched := false

// First, try direct match with PV name as-is
if slices.Contains(userProvidedMappings, pv.PvName) {
pvMatched = true
}

// If no direct match, try resolving the PV name and compare
if !pvMatched {
resolvedPvName, err := resolver.Resolve(pv.PvName)
if err == nil && slices.Contains(userProvidedMappings, resolvedPvName) {
pvMatched = true
}
}

if !pvMatched {
devicesToRemove = append(devicesToRemove, pv.PvName)
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/lvm_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func lvmClusterTest() {
Describe("Storage Class", Serial, func() {
It("should become ready without a default storageclass", func(ctx SpecContext) {
// set default to false
for _, dc := range cluster.Spec.Storage.DeviceClasses {
dc.Default = false
for i := range cluster.Spec.Storage.DeviceClasses {
cluster.Spec.Storage.DeviceClasses[i].Default = false
}

CreateResource(ctx, cluster)
Expand All @@ -83,8 +83,8 @@ func lvmClusterTest() {

Describe("Thick Provisioning", Serial, func() {
It("should become ready if ThinPoolConfig is empty (thick provisioning)", func(ctx SpecContext) {
for _, dc := range cluster.Spec.Storage.DeviceClasses {
dc.ThinPoolConfig = nil
for i := range cluster.Spec.Storage.DeviceClasses {
cluster.Spec.Storage.DeviceClasses[i].ThinPoolConfig = nil
}
CreateResource(ctx, cluster)
VerifyLVMSSetup(ctx, cluster)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/lvm_pvc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func pvcTestThickProvisioning() {
cluster = GetDefaultTestLVMClusterTemplate()

// set ThinPoolConfig to nil
for _, dc := range cluster.Spec.Storage.DeviceClasses {
dc.ThinPoolConfig = nil
for i := range cluster.Spec.Storage.DeviceClasses {
cluster.Spec.Storage.DeviceClasses[i].ThinPoolConfig = nil
}

CreateResource(ctx, cluster)
Expand Down