Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Zimin <[email protected]>
  • Loading branch information
AleksZimin committed Oct 30, 2024
1 parent ac61ff2 commit 47d385a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions images/agent/src/pkg/controller/lvm_volume_group_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func RunLVMVolumeGroupWatcherController(
log.Debug(fmt.Sprintf("[RunLVMVolumeGroupWatcherController] successfully removed the label %s from the LVMVolumeGroup %s", internal.LVGUpdateTriggerLabel, lvg.Name))
}

log.Debug(fmt.Sprintf("[RunLVMVolumeGroupWatcherController] tries to get block device resources for the LVMVolumeGroup %s by the selector %v", lvg.Name, lvg.Spec.BlockDeviceSelector.MatchLabels))
log.Debug(fmt.Sprintf("[RunLVMVolumeGroupWatcherController] tries to get block device resources for the LVMVolumeGroup %s by the selector %v", lvg.Name, lvg.Spec.BlockDeviceSelector))
blockDevices, err := GetAPIBlockDevices(ctx, cl, metrics, lvg.Spec.BlockDeviceSelector)
if err != nil {
log.Error(err, fmt.Sprintf("[RunLVMVolumeGroupWatcherController] unable to get BlockDevices. Retry in %s", cfg.BlockDeviceScanIntervalSec.String()))
Expand All @@ -129,7 +129,8 @@ func RunLVMVolumeGroupWatcherController(

return reconcile.Result{RequeueAfter: cfg.BlockDeviceScanIntervalSec}, nil
}
log.Debug(fmt.Sprintf("[RunLVMVolumeGroupWatcherController] successfully got block device resources for the LVMVolumeGroup %s by the selector %v", lvg.Name, lvg.Spec.BlockDeviceSelector.MatchLabels))
log.Debug(fmt.Sprintf("[RunLVMVolumeGroupWatcherController] successfully got block device resources for the LVMVolumeGroup %s by the selector %v", lvg.Name, lvg.Spec.BlockDeviceSelector))
log.Trace(fmt.Sprintf("[RunLVMVolumeGroupWatcherController] block devices: %v", blockDevices))

valid, reason := validateSpecBlockDevices(lvg, blockDevices)
if !valid {
Expand Down
14 changes: 9 additions & 5 deletions images/agent/src/pkg/controller/lvm_volume_group_watcher_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,19 @@ func validateSpecBlockDevices(lvg *v1alpha1.LVMVolumeGroup, blockDevices map[str
}
}

bdFromOtherNode := make([]string, 0, len(blockDevices))
bdFromOurNode := make([]string, 0, len(blockDevices))
for _, bd := range blockDevices {
if bd.Status.NodeName != lvg.Spec.Local.NodeName {
bdFromOtherNode = append(bdFromOtherNode, bd.Name)
if bd.Status.NodeName == lvg.Spec.Local.NodeName {
bdFromOurNode = append(bdFromOurNode, bd.Name)
}
}

if len(bdFromOtherNode) != 0 {
return false, fmt.Sprintf("block devices %s have different node names from LVMVolumeGroup Local.NodeName", strings.Join(bdFromOtherNode, ","))
if len(bdFromOurNode) == 0 {
bdNames := make([]string, 0, len(blockDevices))
for _, bd := range blockDevices {
bdNames = append(bdNames, bd.Name)
}
return false, fmt.Sprintf("none of specified BlockDevices %s were found on the node %s", lvg.Spec.Local.NodeName, strings.Join(bdNames, ","))
}

return true, ""
Expand Down

0 comments on commit 47d385a

Please sign in to comment.