feat(ssh/zfs): update path resolution logic for scale
This commit is contained in:
parent
55c36d62ff
commit
721d375531
|
|
@ -39,20 +39,26 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
|
||||||
}
|
}
|
||||||
options.idempotent = true;
|
options.idempotent = true;
|
||||||
|
|
||||||
|
options.sudo = _.get(this.options, "zfs.cli.sudoEnabled", false);
|
||||||
|
|
||||||
|
// Run automatic detection first
|
||||||
|
if (typeof this.setZetabyteCustomOptions === "function") {
|
||||||
|
await this.setZetabyteCustomOptions(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manual override comes after automatic detection
|
||||||
|
// Only apply if user explicitly provided non-empty paths
|
||||||
if (
|
if (
|
||||||
this.options.zfs.hasOwnProperty("cli") &&
|
this.options.zfs.hasOwnProperty("cli") &&
|
||||||
this.options.zfs.cli &&
|
this.options.zfs.cli &&
|
||||||
this.options.zfs.cli.hasOwnProperty("paths")
|
this.options.zfs.cli.hasOwnProperty("paths") &&
|
||||||
|
this.options.zfs.cli.paths &&
|
||||||
|
Object.keys(this.options.zfs.cli.paths).length > 0
|
||||||
) {
|
) {
|
||||||
|
// User explicitly configured paths - use them
|
||||||
options.paths = this.options.zfs.cli.paths;
|
options.paths = this.options.zfs.cli.paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.sudo = _.get(this.options, "zfs.cli.sudoEnabled", false);
|
|
||||||
|
|
||||||
if (typeof this.setZetabyteCustomOptions === "function") {
|
|
||||||
await this.setZetabyteCustomOptions(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Zetabyte(options);
|
return new Zetabyte(options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,20 +71,26 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
|
||||||
options.executor = new ZfsSshProcessManager(sshClient);
|
options.executor = new ZfsSshProcessManager(sshClient);
|
||||||
options.idempotent = true;
|
options.idempotent = true;
|
||||||
|
|
||||||
|
options.sudo = _.get(this.options, "zfs.cli.sudoEnabled", false);
|
||||||
|
|
||||||
|
// Run automatic detection first
|
||||||
|
if (typeof this.setZetabyteCustomOptions === "function") {
|
||||||
|
await this.setZetabyteCustomOptions(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manual override comes after automatic detection
|
||||||
|
// Only apply if user explicitly provided non-empty paths
|
||||||
if (
|
if (
|
||||||
this.options.zfs.hasOwnProperty("cli") &&
|
this.options.zfs.hasOwnProperty("cli") &&
|
||||||
this.options.zfs.cli &&
|
this.options.zfs.cli &&
|
||||||
this.options.zfs.cli.hasOwnProperty("paths")
|
this.options.zfs.cli.hasOwnProperty("paths") &&
|
||||||
|
this.options.zfs.cli.paths &&
|
||||||
|
Object.keys(this.options.zfs.cli.paths).length > 0
|
||||||
) {
|
) {
|
||||||
|
// User explicitly configured paths - use them
|
||||||
options.paths = this.options.zfs.cli.paths;
|
options.paths = this.options.zfs.cli.paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.sudo = _.get(this.options, "zfs.cli.sudoEnabled", false);
|
|
||||||
|
|
||||||
if (typeof this.setZetabyteCustomOptions === "function") {
|
|
||||||
await this.setZetabyteCustomOptions(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Zetabyte(options);
|
return new Zetabyte(options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -112,22 +118,33 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
|
||||||
if (!options.hasOwnProperty("paths")) {
|
if (!options.hasOwnProperty("paths")) {
|
||||||
const majorMinor = await this.getSystemVersionMajorMinor();
|
const majorMinor = await this.getSystemVersionMajorMinor();
|
||||||
const isScale = await this.getIsScale();
|
const isScale = await this.getIsScale();
|
||||||
|
|
||||||
if (!isScale && Number(majorMinor) >= 12) {
|
if (!isScale && Number(majorMinor) >= 12) {
|
||||||
|
// TrueNAS CORE/Enterprise version 12+
|
||||||
options.paths = {
|
options.paths = {
|
||||||
zfs: "/usr/local/sbin/zfs",
|
zfs: "/usr/local/sbin/zfs",
|
||||||
zpool: "/usr/local/sbin/zpool",
|
zpool: "/usr/local/sbin/zpool",
|
||||||
sudo: "/usr/local/bin/sudo",
|
sudo: "/usr/local/bin/sudo",
|
||||||
chroot: "/usr/sbin/chroot",
|
chroot: "/usr/sbin/chroot",
|
||||||
};
|
};
|
||||||
}
|
} else if (isScale) {
|
||||||
|
if (Number(majorMinor) >= 25) {
|
||||||
if (isScale && Number(majorMinor) >= 25) {
|
// TrueNAS SCALE version 25+ (paths changed to /usr/sbin in 25.04)
|
||||||
options.paths = {
|
options.paths = {
|
||||||
zfs: "/usr/sbin/zfs",
|
zfs: "/usr/sbin/zfs",
|
||||||
zpool: "/usr/sbin/zpool",
|
zpool: "/usr/sbin/zpool",
|
||||||
sudo: "/usr/bin/sudo",
|
sudo: "/usr/bin/sudo",
|
||||||
chroot: "/usr/sbin/chroot",
|
chroot: "/usr/sbin/chroot",
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
// TrueNAS SCALE versions before 25
|
||||||
|
options.paths = {
|
||||||
|
zfs: "/usr/local/sbin/zfs",
|
||||||
|
zpool: "/usr/local/sbin/zpool",
|
||||||
|
sudo: "/usr/bin/sudo",
|
||||||
|
chroot: "/usr/sbin/chroot",
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2179,8 +2196,19 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
|
||||||
async getIsScale() {
|
async getIsScale() {
|
||||||
const systemVersion = await this.getSystemVersion();
|
const systemVersion = await this.getSystemVersion();
|
||||||
|
|
||||||
if (systemVersion.v2 && systemVersion.v2.toLowerCase().includes("scale")) {
|
if (systemVersion.v2) {
|
||||||
return true;
|
const versionLower = systemVersion.v2.toLowerCase();
|
||||||
|
// Check for explicit "scale" in version string
|
||||||
|
if (versionLower.includes("scale")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// TrueNAS 25+ doesn't include "SCALE" in version string, but versions 25+ are SCALE-only
|
||||||
|
if (versionLower.includes("truenas")) {
|
||||||
|
const majorVersion = await this.getSystemVersionMajor();
|
||||||
|
if (Number(majorVersion) >= 25) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue