check guid of common snapshot, fix #218

This commit is contained in:
Edwin Eefting
2023-09-26 16:16:32 +02:00
parent aac62f3fe6
commit 7cffec1d26
2 changed files with 115 additions and 3 deletions

View File

@ -58,6 +58,13 @@ class ZfsDataset:
"""
self.zfs_node.error("{}: {}".format(self.name, txt))
def warning(self, txt):
"""
Args:
:type txt: str
"""
self.zfs_node.warning("{}: {}".format(self.name, txt))
def debug(self, txt):
"""
Args:
@ -822,9 +829,13 @@ class ZfsDataset:
return None
else:
for source_snapshot in reversed(self.snapshots):
if target_dataset.find_snapshot(source_snapshot):
source_snapshot.debug("common snapshot")
return source_snapshot
target_snapshot=target_dataset.find_snapshot(source_snapshot)
if target_snapshot:
if source_snapshot.properties['guid']!=target_snapshot.properties['guid']:
source_snapshot.warning("Common snapshot has invalid guid, ignoring.")
else:
source_snapshot.debug("common snapshot")
return source_snapshot
target_dataset.error("Cant find common snapshot with source.")
raise (Exception("You probably need to delete the target dataset to fix this."))