From c48a992385726d693e0dd1c0113ace0dec8d2813 Mon Sep 17 00:00:00 2001 From: Kevin Adams Date: Mon, 25 May 2026 08:08:41 -0400 Subject: [PATCH] feat: add Help button to TrueNAS storage panel and ship docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Inject pveOnlineHelpInfo entry in truenas-storage.js so PVE wires the Help button automatically via the StorageBase framework - Add onlineHelp: 'storage_truenas' to the input panel definition - Add ui/truenas-storage-help.html — local help page installed to /usr/share/pve-docs/truenas-storage.html (no internet required) - Add docs/getting-started.md and docs/architecture.md - Update postinst/postrm to install and remove the help HTML file - Update build.yml to include the help HTML in the package staging dir Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/build.yml | 5 +- docs/architecture.md | 620 +++++++++++++++++++++++++++++++++++ docs/getting-started.md | 307 +++++++++++++++++ packaging/DEBIAN/postinst | 4 + packaging/DEBIAN/postrm | 6 +- ui/truenas-storage-help.html | 231 +++++++++++++ ui/truenas-storage.js | 8 + 7 files changed, 1177 insertions(+), 4 deletions(-) create mode 100644 docs/architecture.md create mode 100644 docs/getting-started.md create mode 100644 ui/truenas-storage-help.html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 214baac..b1e09ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -159,8 +159,9 @@ jobs: chmod 0755 "${STAGING}/DEBIAN/postinst" "${STAGING}/DEBIAN/postrm" # Plugin files (postinst copies these to their final destinations) - cp perl5/PVE/Storage/Custom/TrueNAS.pm "${STAGING}/usr/share/freenas-proxmox/TrueNAS.pm" - cp ui/truenas-storage.js "${STAGING}/usr/share/freenas-proxmox/truenas-storage.js" + cp perl5/PVE/Storage/Custom/TrueNAS.pm "${STAGING}/usr/share/freenas-proxmox/TrueNAS.pm" + cp ui/truenas-storage.js "${STAGING}/usr/share/freenas-proxmox/truenas-storage.js" + cp ui/truenas-storage-help.html "${STAGING}/usr/share/freenas-proxmox/truenas-storage-help.html" echo "==> Package contents:" find "${STAGING}" | sort diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..3a126a6 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,620 @@ +# freenas-proxmox v3.0 — Architecture & Developer Guide + +## Table of Contents + +1. [Architecture Overview](#1-architecture-overview) +2. [Per-VM iSCSI Target Model](#2-per-vm-iscsi-target-model) +3. [The `iscsi://` Path Model](#3-the-iscsi-path-model) +4. [API Flow — TrueNAS REST v2.0](#4-api-flow--truenas-rest-v20) +5. [alloc_image Deep Dive](#5-alloc_image-deep-dive) +6. [free_image Deep Dive](#6-free_image-deep-dive) +7. [Build Pipeline and Version/Channel Routing](#7-build-pipeline-and-versionchannel-routing) +8. [Debugging Guide](#8-debugging-guide) +9. [Contributing](#9-contributing) + +--- + +## 1. Architecture Overview + +### Where This Plugin Sits + +Proxmox VE organizes storage backends through a plugin registry. Every storage type — directory, LVM, Ceph, ZFS-over-iSCSI — is a Perl module that subclasses `PVE::Storage::Plugin`. The `pvedaemon` process loads all registered storage plugins at startup and delegates storage operations (create volume, delete volume, list volumes, etc.) to the correct plugin based on the `type` field in `/etc/pve/storage.cfg`. + +`PVE::Storage::Custom::TrueNAS` is loaded by PVE's auto-discovery mechanism. Any module installed under `/usr/share/perl5/PVE/Storage/Custom/` is automatically registered as a custom storage type. No patching of PVE's core `ZFSPlugin.pm`, `pvemanagerlib.js`, or `apidoc.js` is required — this is the fundamental architectural change from v2.x. + +``` +Proxmox VE (pvedaemon) + └─ PVE::Storage # core storage dispatch + └─ PVE::Storage::Custom::TrueNAS # this plugin + └─ TrueNAS REST API v2.0 # all state lives here + ├─ /pool/dataset # zvol create/delete/resize + └─ /iscsi/* # extent, target, targetextent CRUD +``` + +### What the Plugin Manages + +The plugin manages the entire lifecycle of iSCSI-backed block devices on behalf of Proxmox VE: + +- **ZFS volumes (zvols)** — the actual block storage, created and destroyed via `POST /pool/dataset` and `DELETE /pool/dataset/id/{id}` +- **iSCSI extents** — TrueNAS's representation of a device to export over iSCSI, one per zvol +- **iSCSI targets** — the access point a client connects to, one per VM (`proxmox-vm-`) +- **targetextent mappings** — the join record linking an extent to a target at a specific LUN ID + +The plugin does NOT manage the iSCSI initiator side. QEMU's built-in libiscsi opens the `iscsi://` URI returned by `path()` directly, without any host-side session management via `iscsiadm`. + +### What the Plugin Does Not Do + +- **Pool listing**: Proxmox's `status()` call returns pool capacity via the TrueNAS API, but ZFS pool enumeration for the "Add Storage" wizard still requires SSH access through PVE's upstream `ZFSPoolPlugin.pm`. This is a Proxmox limitation outside the plugin's scope. +- **Snapshots on PVE 8.x**: The `volume_snapshot` family of methods is defined but will return an unsupported error on PVE 8. PVE 9.0's Snapshot-as-Volume-Chains feature is the target integration point (v3.1.0, ADR-008). +- **TPM state disks**: swtpm (the virtual TPM backend) cannot use `iscsi://` URIs; it requires a local filesystem path. TPM disks must be placed on a different storage type. + +### Installed File Locations + +| File | Destination on Proxmox host | +|---|---| +| `perl5/PVE/Storage/Custom/TrueNAS.pm` | `/usr/share/perl5/PVE/Storage/Custom/TrueNAS.pm` | +| `ui/truenas-storage.js` | `/usr/share/pve-manager/js/truenas-storage.js` | +| One `' LOG_FILE="/var/log/freenas-proxmox-install.log" @@ -25,6 +26,9 @@ install_ui() { log "Installing ${JS_DST}" cp "${INSTALL_DIR}/truenas-storage.js" "$JS_DST" + log "Installing ${HELP_DST}" + cp "${INSTALL_DIR}/truenas-storage-help.html" "$HELP_DST" + if grep -qF 'truenas-storage.js' "$TPL" 2>/dev/null; then log "index.html.tpl already has truenas-storage.js — skipping" return 0 diff --git a/packaging/DEBIAN/postrm b/packaging/DEBIAN/postrm index 1ad352b..b24614d 100644 --- a/packaging/DEBIAN/postrm +++ b/packaging/DEBIAN/postrm @@ -4,6 +4,7 @@ set -e PLUGIN_DST="/usr/share/perl5/PVE/Storage/Custom/TrueNAS.pm" JS_DST="/usr/share/pve-manager/js/truenas-storage.js" +HELP_DST="/usr/share/pve-docs/truenas-storage.html" TPL="/usr/share/pve-manager/index.html.tpl" LOG_FILE="/var/log/freenas-proxmox-install.log" @@ -12,7 +13,8 @@ log() { } remove_ui() { - rm -f "$JS_DST" && log "Removed ${JS_DST}" + rm -f "$JS_DST" && log "Removed ${JS_DST}" + rm -f "$HELP_DST" && log "Removed ${HELP_DST}" if [ -f "$TPL" ] && grep -qF 'truenas-storage.js' "$TPL"; then log "Removing