linstor: Fix ZFS snapshot backup (#10219)

Linstor plugin used the wrong zfs dataset path to hide/unhide
the snapshot device.
Also don't use the full path to the zfs binary.
This commit is contained in:
Rene Peinthor 2025-01-21 11:10:17 +01:00 committed by GitHub
parent 70776b067a
commit 1ff68cf9b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2025-01-20]
### Fixed
- Volume snapshots on zfs used the wrong dataset path to hide/unhide snapdev
## [2024-12-13]
### Fixed

View File

@ -45,11 +45,17 @@ public final class LinstorBackupSnapshotCommandWrapper
{
private static final Logger s_logger = Logger.getLogger(LinstorBackupSnapshotCommandWrapper.class);
private static String zfsDatasetName(String zfsFullSnapshotUrl) {
String zfsFullPath = zfsFullSnapshotUrl.substring(6);
int atPos = zfsFullPath.indexOf('@');
return atPos >= 0 ? zfsFullPath.substring(0, atPos) : zfsFullPath;
}
private String zfsSnapdev(boolean hide, String zfsUrl) {
Script script = new Script("/usr/bin/zfs", Duration.millis(5000));
Script script = new Script("zfs", Duration.millis(5000));
script.add("set");
script.add("snapdev=" + (hide ? "hidden" : "visible"));
script.add(zfsUrl.substring(6)); // cutting zfs://
script.add(zfsDatasetName(zfsUrl)); // cutting zfs:// and @snapshotname
return script.execute();
}
@ -133,10 +139,10 @@ public final class LinstorBackupSnapshotCommandWrapper
s_logger.info("Src: " + srcPath + " | " + src.getName());
if (srcPath.startsWith("zfs://")) {
zfsHidden = true;
if (zfsSnapdev(false, srcPath) != null) {
if (zfsSnapdev(false, src.getPath()) != null) {
return new CopyCmdAnswer("Unable to unhide zfs snapshot device.");
}
srcPath = "/dev/" + srcPath.substring(6);
srcPath = "/dev/zvol/" + srcPath.substring(6);
}
secondaryPool = storagePoolMgr.getStoragePoolByURI(dstDataStore.getUrl());