Skip to content

Commit

Permalink
Changes blockdevice deletion logic
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Zimin <[email protected]>
  • Loading branch information
ViktorKram authored and AleksZimin committed Dec 27, 2023
1 parent 08d9b7d commit 8828631
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion images/agent/internal/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
AvailableBlockDevice = "available_block_device"
SdsNodeConfigurator = "storage.deckhouse.io/sds-node-configurator"
LVMVGHealthOperational = "Operational"
LVMVGHealthNonOperational = "Nonoperational"
LVMVGHealthNonOperational = "NonOperational"
)

var (
Expand Down
17 changes: 13 additions & 4 deletions images/agent/pkg/controller/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion images/agent/pkg/controller/watcher_lvm_volume_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (

Failed = "Failed"

NoOperational = "Nonoperational"
NoOperational = "NonOperational"
Operational = "Operational"

delAnnotation = "storage.deckhouse.io/sds-delete-vg"
Expand Down

0 comments on commit 8828631

Please sign in to comment.