diff --git a/images/agent/internal/const.go b/images/agent/internal/const.go index 735011e2..c0fcb609 100644 --- a/images/agent/internal/const.go +++ b/images/agent/internal/const.go @@ -25,7 +25,7 @@ const ( AvailableBlockDevice = "available_block_device" SdsNodeConfigurator = "storage.deckhouse.io/sds-node-configurator" LVMVGHealthOperational = "Operational" - LVMVGHealthNonOperational = "Nonoperational" + LVMVGHealthNonOperational = "NonOperational" ) var ( diff --git a/images/agent/pkg/controller/block_device.go b/images/agent/pkg/controller/block_device.go index 2bcb4bf3..7b20e534 100644 --- a/images/agent/pkg/controller/block_device.go +++ b/images/agent/pkg/controller/block_device.go @@ -192,8 +192,7 @@ func RemoveDeprecatedAPIDevices( } for name, device := range apiBlockDevices { - if checkAPIBlockDeviceDeprecated(name, actualCandidates) && - device.Status.NodeName == nodeName { + if shouldDeleteBlockDevice(device, actualCandidates, nodeName) { err := DeleteAPIBlockDevice(ctx, cl, metrics, name) if err != nil { log.Error(err, fmt.Sprintf("[RunBlockDeviceController] unable to delete APIBlockDevice, name: %s", name)) @@ -206,8 +205,18 @@ func RemoveDeprecatedAPIDevices( } } -func checkAPIBlockDeviceDeprecated(apiDeviceName string, actualCandidates map[string]struct{}) bool { - _, ok := actualCandidates[apiDeviceName] +func shouldDeleteBlockDevice(bd v1alpha1.BlockDevice, actualCandidates map[string]struct{}, nodeName string) bool { + if bd.Status.NodeName == nodeName && + bd.Status.Consumable && + isBlockDeviceDeprecated(bd.Name, actualCandidates) { + return true + } + + return false +} + +func isBlockDeviceDeprecated(blockDevice string, actualCandidates map[string]struct{}) bool { + _, ok := actualCandidates[blockDevice] return !ok } diff --git a/images/agent/pkg/controller/watcher_lvm_volume_group.go b/images/agent/pkg/controller/watcher_lvm_volume_group.go index dca70e37..384822e5 100644 --- a/images/agent/pkg/controller/watcher_lvm_volume_group.go +++ b/images/agent/pkg/controller/watcher_lvm_volume_group.go @@ -66,7 +66,7 @@ func RunWatcherLVMVGController( log.Warning(fmt.Sprintf(`Added request, namespace: "%s" name: "%s", to requeue`, request.Namespace, request.Name)) return reconcile.Result{ RequeueAfter: cfg.VolumeGroupScanInterval * time.Second, - }, err + }, nil } log.Info(fmt.Sprintf(`Reconcile of RunWatcherLVMVGController on request, name: "%s" ends`, request.Name)) diff --git a/images/agent/pkg/controller/watcher_lvm_volume_group_constants.go b/images/agent/pkg/controller/watcher_lvm_volume_group_constants.go index d5cc3bf5..677ca3c4 100644 --- a/images/agent/pkg/controller/watcher_lvm_volume_group_constants.go +++ b/images/agent/pkg/controller/watcher_lvm_volume_group_constants.go @@ -22,7 +22,7 @@ const ( Failed = "Failed" - NoOperational = "Nonoperational" + NoOperational = "NonOperational" Operational = "Operational" delAnnotation = "storage.deckhouse.io/sds-delete-vg"