Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/add-data-wipe' into data-wipe-un…
Browse files Browse the repository at this point in the history
…it-tests
  • Loading branch information
asergunov committed Feb 25, 2025
2 parents b329331 + 9437bcd commit 2144bfc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions crds/lvmlogicalvolume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ spec:
(!has(oldSelf.thick) || !has(oldSelf.thick.contiguous))
) || (
has(self.thick) && has(self.thick.contiguous) &&
has(oldSelf.thick) && has(oldSelf.thick.contiguous) &&
self.thick.contiguous == oldSelf.thick.contiguous
has(oldSelf.thick) && has(oldSelf.thick.contiguous)
)
message: "Field 'contiguous' is immutable and cannot be added if not specified at creation."
required:
Expand Down
14 changes: 8 additions & 6 deletions images/agent/src/internal/controller/llv/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,21 +605,23 @@ func (r *Reconciler) deleteLVIfNeeded(ctx context.Context, vgName string, llv *v
if llv.Spec.Type == internal.Thick && llv.Spec.Thick != nil && llv.Spec.Thick.VolumeCleanup != nil {
method := *llv.Spec.Thick.VolumeCleanup
lvName := llv.Spec.ActualLVNameOnTheNode
started, failedMethod := r.startCleanupRunning(vgName, lvName)
started, prevFailedMethod := r.startCleanupRunning(vgName, lvName)
if !started {
r.log.Debug(fmt.Sprintf("[deleteLVIfNeeded] cleanup already running for LV %s in VG %s", lvName, vgName))
return false, errAlreadyRunning
}
r.log.Trace(fmt.Sprintf("[deleteLVIfNeeded] starting cleaning up for LV %s in VG %s with method %s", lvName, vgName, method))
defer func() {
r.log.Trace(fmt.Sprintf("[deleteLVIfNeeded] stopping cleaning up for LV %s in VG %s with method %s", lvName, vgName, method))
err := r.stopCleanupRunning(vgName, lvName, failedMethod)
err := r.stopCleanupRunning(vgName, lvName, prevFailedMethod)
if err != nil {
r.log.Error(err, fmt.Sprintf("[deleteLVIfNeeded] can't unregister running cleanup for LV %s in VG %s", lvName, vgName))
}
}()
if failedMethod != nil && *failedMethod == method {
r.log.Debug(fmt.Sprintf("[deleteLVIfNeeded] was already failed with method %s for LV %s in VG %s", *failedMethod, lvName, vgName))

// prevent doing cleanup with previously failed method
if prevFailedMethod != nil && *prevFailedMethod == method {
r.log.Debug(fmt.Sprintf("[deleteLVIfNeeded] was already failed with method %s for LV %s in VG %s", *prevFailedMethod, lvName, vgName))
return false, errCleanupSameAsPreviouslyFailed
}
err := r.llvCl.UpdatePhaseIfNeeded(
Expand All @@ -632,14 +634,14 @@ func (r *Reconciler) deleteLVIfNeeded(ctx context.Context, vgName string, llv *v
r.log.Error(err, "[deleteLVIfNeeded] changing phase to Cleaning")
return true, fmt.Errorf("changing phase to Cleaning :%w", err)
}
failedMethod = &method
prevFailedMethod = &method
r.log.Debug(fmt.Sprintf("[deleteLVIfNeeded] running cleanup for LV %s in VG %s with method %s", lvName, vgName, method))
err = utils.VolumeCleanup(ctx, r.log, utils.OsDeviceOpener(), vgName, lvName, method)
if err != nil {
r.log.Error(err, fmt.Sprintf("[deleteLVIfNeeded] unable to clean up LV %s in VG %s with method %s", lvName, vgName, method))
return true, err
}
failedMethod = nil
prevFailedMethod = nil
}

cmd, err := utils.RemoveLV(vgName, llv.Spec.ActualLVNameOnTheNode)
Expand Down

0 comments on commit 2144bfc

Please sign in to comment.