Skip to content

Commit

Permalink
linstor: backupsnapshot improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Oct 4, 2024
1 parent ca62617 commit e246e7e
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,23 @@ private String convertImageToQCow2(
// NOTE: the qemu img will also contain the drbd metadata at the end
final QemuImg qemu = new QemuImg(waitMilliSeconds);
qemu.convert(srcFile, dstFile);
s_logger.info("Backup snapshot " + srcFile + " to " + dstPath);
s_logger.info(String.format("Backup snapshot '%s' to '%s'", srcPath, dstPath));
return dstPath;
}

private SnapshotObjectTO setCorrectSnapshotSize(final SnapshotObjectTO dst, final String dstPath) {
final File snapFile = new File(dstPath);
final long size = snapFile.exists() ? snapFile.length() : 0;
long size;
if (snapFile.exists()) {
size = snapFile.length();
} else {
s_logger.warn(String.format("Snapshot file %s does not exist. Reporting size 0", dstPath));
size = 0;
}

final SnapshotObjectTO snapshot = new SnapshotObjectTO();
snapshot.setPath(dst.getPath() + File.separator + dst.getName());
snapshot.setPhysicalSize(size);
return snapshot;
dst.setPath(dst.getPath() + File.separator + dst.getName());
dst.setPhysicalSize(size);
return dst;
}

@Override
Expand Down Expand Up @@ -151,6 +156,7 @@ public CopyCmdAnswer execute(LinstorBackupSnapshotCommand cmd, LibvirtComputingR
s_logger.info("Backup shrunk " + dstPath + " to actual size " + src.getVolume().getSize());

SnapshotObjectTO snapshot = setCorrectSnapshotSize(dst, dstPath);
s_logger.info(String.format("Actual file size for '%s' is %d", dstPath, snapshot.getPhysicalSize()));
return new CopyCmdAnswer(snapshot);
} catch (final Exception e) {
final String error = String.format("Failed to backup snapshot with id [%s] with a pool %s, due to %s",
Expand Down

0 comments on commit e246e7e

Please sign in to comment.