Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[controller] Add parallel reconciliation to lvm_logical_volume_watcher. Add VG size validation to lvm_volume_group_watcher #40

Merged
merged 21 commits into from
Apr 25, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
some fixes
Signed-off-by: Aleksandr Zimin <alexandr.zimin@flant.com>
AleksZimin committed Apr 24, 2024
commit 8d1c793e1929a1b90584d80b64843bfc893c0e08
60 changes: 30 additions & 30 deletions images/agent/pkg/controller/lvm_logical_volume_watcher.go
Original file line number Diff line number Diff line change
@@ -127,40 +127,40 @@ func RunLVMLogicalVolumeWatcherController(
q.Add(request)
log.Debug(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] UpdateFunc ends reconciliation of LLV: %s", newLLV.Name))
},
DeleteFunc: func(ctx context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] DeleteFunc starts reconciliation of LLV: %s", e.Object.GetName()))

llv, ok := e.Object.(*v1alpha1.LVMLogicalVolume)
if !ok {
err = errors.New("unable to cast event object to a given type")
log.Error(err, "[DeleteFunc] an error occurs while handling update event")
return
}
log.Trace("[RunLVMLogicalVolumeWatcherController] DeleteFunc got LVMLogicalVolume: ", llv.Name, llv)
// DeleteFunc: func(ctx context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
// log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] DeleteFunc starts reconciliation of LLV: %s", e.Object.GetName()))

// llv, ok := e.Object.(*v1alpha1.LVMLogicalVolume)
// if !ok {
// err = errors.New("unable to cast event object to a given type")
// log.Error(err, "[DeleteFunc] an error occurs while handling update event")
// return
// }
// log.Trace("[RunLVMLogicalVolumeWatcherController] DeleteFunc got LVMLogicalVolume: ", llv.Name, llv)

lvg, err := getLVMVolumeGroup(ctx, cl, metrics, "", llv.Spec.LvmVolumeGroupName)
if err != nil {
log.Error(err, fmt.Sprintf("[DeleteFunc] unable to get the LVMVolumeGroup, name: %s", llv.Spec.LvmVolumeGroupName))
err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("Unable to get selected LVMVolumeGroup, err: %s", err.Error()))
if err != nil {
log.Error(err, "[DeleteFunc] unable to update LVMLogicalVolume Phase")
}
return
}
// lvg, err := getLVMVolumeGroup(ctx, cl, metrics, "", llv.Spec.LvmVolumeGroupName)
// if err != nil {
// log.Error(err, fmt.Sprintf("[DeleteFunc] unable to get the LVMVolumeGroup, name: %q. Skip deletion of the LVMLogicalVolume %q", llv.Spec.LvmVolumeGroupName, llv.Name))
// err = updateLVMLogicalVolumePhase(ctx, cl, log, metrics, llv, failedStatusPhase, fmt.Sprintf("Unable to get selected LVMVolumeGroup, err: %s", err.Error()))
// if err != nil {
// log.Error(err, "[DeleteFunc] unable to update LVMLogicalVolume Phase")
// }
// return
// }

if !belongsToNode(lvg, cfg.NodeName) {
log.Debug(fmt.Sprintf("[DeleteFunc] the LVMVolumeGroup %s does not belongs to the current node: %s. Reconciliation stopped", lvg.Name, cfg.NodeName))
return
}
log.Debug(fmt.Sprintf("[DeleteFunc] the LVMVolumeGroup %s belongs to the current node: %s", lvg.Name, cfg.NodeName))
// if !belongsToNode(lvg, cfg.NodeName) {
// log.Debug(fmt.Sprintf("[DeleteFunc] the LVMVolumeGroup %s does not belongs to the current node: %s. Skip deletion of the LVMLogicalVolume %q", lvg.Name, cfg.NodeName))
// return
// }
// log.Debug(fmt.Sprintf("[DeleteFunc] the LVMVolumeGroup %s belongs to the current node: %s", lvg.Name, cfg.NodeName))

err = deleteLVIfExists(log, lvg.Spec.ActualVGNameOnTheNode, llv.Spec.ActualLVNameOnTheNode)
if err != nil {
log.Error(err, fmt.Sprintf("[DeleteFunc] an error occured while trying to delete LV for LVMLogicalVolume %s", llv.Name))
}
// err = deleteLVIfExists(log, lvg.Spec.ActualVGNameOnTheNode, llv.Spec.ActualLVNameOnTheNode)
// if err != nil {
// log.Error(err, fmt.Sprintf("[DeleteFunc] an error occured while trying to delete LV for LVMLogicalVolume %s", llv.Name))
// }

log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] DeleteFunc ends reconciliation of LLV: %s", llv.Name))
},
// log.Info(fmt.Sprintf("[RunLVMLogicalVolumeWatcherController] DeleteFunc ends reconciliation of LLV: %s", llv.Name))
// },
})

if err != nil {
8 changes: 1 addition & 7 deletions images/agent/pkg/controller/lvm_volume_group_watcher.go
Original file line number Diff line number Diff line change
@@ -233,13 +233,7 @@ func ReconcileLVMVG(
return true, err
}

size, err := resource.ParseQuantity(bd.Status.Size)
if err != nil {
log.Error(err, fmt.Sprintf("[ReconcileLVMVG] unable to parse quantity for BlockDevice %s size", bd.Name))
return false, err
}

totalVGSize += size.Value()
totalVGSize += bd.Status.Size.Value()
}

var totalThinPoolSize int64