Refactor snapshot parent updates: replace full metadata reload with UpdateSnapshotParentID method, enhance functional test logging, and add CleanOnRestore option.
This commit is contained in:
14
manager.go
14
manager.go
@ -207,18 +207,8 @@ func (data *SnapshotManagerData) DeleteSnapshot(ctx context.Context, snapshotID
|
||||
// Update parent references for any snapshots that have this one as a parent
|
||||
for _, info := range allSnapshots {
|
||||
if info.ParentID == snapshotID {
|
||||
// Get the full snapshot details
|
||||
childSnapshot, err := data.metadataStore.GetSnapshotMetadata(ctx, info.ID)
|
||||
if err != nil {
|
||||
data.logger.Printf("WARNING: failed to get child snapshot %s details: %v", info.ID, err)
|
||||
continue
|
||||
}
|
||||
|
||||
// Update the parent ID to point to the deleted snapshot's parent
|
||||
childSnapshot.ParentID = parentID
|
||||
|
||||
// Save the updated snapshot
|
||||
if err := data.metadataStore.SaveSnapshotMetadata(ctx, *childSnapshot); err != nil {
|
||||
// Используем новый, более надежный метод для обновления только parent_id
|
||||
if err := data.metadataStore.UpdateSnapshotParentID(ctx, info.ID, parentID); err != nil {
|
||||
data.logger.Printf("WARNING: failed to update parent reference for snapshot %s: %v", info.ID, err)
|
||||
} else {
|
||||
data.logger.Printf("Updated parent reference for snapshot %s from %s to %s", info.ID, snapshotID, parentID)
|
||||
|
Reference in New Issue
Block a user