fix(democratic-csi): unique NVMe host NQN per node#409
Conversation
All democratic-csi NVMe-oF node plugins connect to TrueNAS with the same host NQN (uuid:941e4f03-...), baked into the container image. Because the DaemonSet runs one image on every node and we don't mount the host's /etc/nvme, every node presents to TrueNAS as the same NVMe initiator — removing per-host isolation at the fabric layer and risking data integrity if two nodes ever attach the same namespace. Add a targeted kustomize patch (the chart's node template has no initContainers hook) to the three NVMe-oF node DaemonSets: an initContainer derives a deterministic host NQN + host ID from the node's /etc/machine-id (unique per node, stable across reboots) and writes them into an emptyDir mounted over /etc/nvme in the csi-driver container. Deterministic derivation keeps the NQN stable so reconnects and any future TrueNAS host ACL keep matching. Fixes #404 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ABCDdxkj3rbL6jF1QA5EwM
Record that the baked-hostnqn defect is tracked upstream as democratic-csi/democratic-csi#451, that the maintainer's generate-if-missing step is dead code while the Dockerfile still bakes the file (so no image past our pin fixes it), and the exact condition under which this patch can be removed. Also note why the deterministic machine-id derivation is preferred over upstream's random-on-first-start. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ABCDdxkj3rbL6jF1QA5EwM
Upstream research: this defect is tracked as democratic-csi#451, and this patch is the right fix to keepChecked whether upstream democratic-csi already solves or tracks the baked-in hostnqn, to decide if we should prefer a native mechanism over this patch. Findings (source-grounded): Tracked upstream, open: democratic-csi/democratic-csi#451 — "NVMEoF driver uses NQN configured during container build stage" (open since 2025-02-04). It's the only hostnqn-related issue/PR in either repo and describes our exact defect. Root cause confirmed verbatim in source: the image — the exact NQN we observe on every node. Upstream's attempted fix is dead code: the maintainer added generate-if-missing logic to No simpler native option exists:
Why this patch is actually better than upstream: deriving deterministically from Removal condition (added to the patch header comment): drop this patch only once #451's Dockerfile stops baking |
Closes #404.
Problem
All democratic-csi NVMe-oF node plugins connect to TrueNAS with the same host NQN
uuid:941e4f03-..., baked into the democratic-csi container image. The DaemonSet runs one image on every node and we don't mount the host's/etc/nvme(node.driver.nvmeDirMountEnableddefaults false), so every node presents to TrueNAS as the same NVMe initiator — no per-host isolation at the fabric layer, and a data-integrity risk if two nodes ever attach the same namespace. Confirmed identical on ocp/hpg5/p330.Fix
The chart's node template has no
initContainershook, so this is a targeted kustomizepatchesentry (patches/nvmeof-unique-hostnqn.yaml) applied by name regex to the three NVMe-oF node DaemonSets (ssd/fast/cold):/etc/machine-id(32 hex = a 128-bit id, unique per node and stable across reboots), formats it into UUID shape, and writeshostnqn/hostidinto anemptyDirmounted over/etc/nvmein thecsi-drivercontainer.nvme gen-hostnqnrandom) so the NQN is stable — reconnects and any future TrueNAS host ACL keep matching.sh+coreutils.Validation
kustomize build --enable-helmrenders the initContainer + emptyDir + csi-driver mount on exactly the 3 nvmeof node DaemonSets; the other 6 (iscsi/nfs) are untouched.ce8235e7-..., hpg5de69ca75-...).Rollout notes
ctrl-loss-tmo=-1); new attaches and post-reboot reconnects use the unique NQN, so it converges as volumes cycle / nodes drain.nvme disconnecton teardown is unaffected (keyed on device/subsystem, not host NQN).discovery.confis intentionally not recreated in the emptyDir — thefreenas-api-nvmeofdriver connects to explicit transports from its config and doesn't use nvme discovery.Follow-ups (not in this PR)
/etc/iscsi/initiatorname.iscsi) duplication was not conclusively verified (host file absent); tracked as the NVMe-oF: democratic-csi node plugins share one host NQN across all nodes #404 iSCSI check./etc/nvme/hostnqnduplication (serves only each node's local boot disk) remains as low-priority cosmetic cleanup.🤖 Generated with Claude Code
https://claude.ai/code/session_01ABCDdxkj3rbL6jF1QA5EwM