Revert "v0.4.65: Local directory ISO source (bind-mount workaround for Unraid)"

This reverts commit 72a2089c98.
This commit is contained in:
Miles Ward
2026-05-28 10:47:17 -04:00
parent 761489761c
commit 07e7c18698
12 changed files with 29 additions and 1027 deletions
+2 -59
View File
@@ -17,15 +17,8 @@ use tokio::io::AsyncWriteExt;
///
/// The default is `Local` — uploaded ISOs sit in `<iso_dir>/<id>.iso`.
/// `Nfs` entries point at a file inside a remote share that the
/// `NfsManager` is keeping mounted. `LocalDir` (v0.4.65) entries point
/// at a file inside an operator-registered directory that's
/// **bind-mounted into the container** from the host — the workaround
/// for environments (Unraid, OpenShift restricted SCC) where the host
/// kernel doesn't have NFS client modules loaded and in-container
/// mounts can't succeed regardless of CAP_SYS_ADMIN.
///
/// We resolve every variant's on-disk path lazily in
/// [`IsoStore::iso_path_for`].
/// `NfsManager` is keeping mounted. We resolve the on-disk path lazily
/// in [`IsoStore::iso_path_for`] using the `nfs_root` set at startup.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum IsoSource {
@@ -36,13 +29,6 @@ pub enum IsoSource {
/// Path relative to the mount point — typically just the filename.
relative_path: String,
},
/// v0.4.65: operator-registered host directory bind-mounted into the
/// container. Path resolution looks up `dir_id` in the IsoStore's
/// `local_dir_roots` map, then joins `relative_path`.
LocalDir {
dir_id: String,
relative_path: String,
},
}
/// Where the ISO lands in the PXE menu hierarchy.
@@ -182,10 +168,6 @@ pub struct IsoStore {
/// [`IsoStore::set_nfs_root`]; required for resolving any
/// `IsoSource::Nfs` entry.
nfs_root: Arc<RwLock<Option<PathBuf>>>,
/// v0.4.65: map of operator-registered directory id → absolute path
/// inside the container. Used to resolve `IsoSource::LocalDir`
/// entries to a real on-disk path. Maintained by `LocalDirManager`.
local_dir_roots: Arc<RwLock<HashMap<String, PathBuf>>>,
inner: Arc<RwLock<Inner>>,
}
@@ -194,26 +176,10 @@ impl IsoStore {
Self {
iso_dir: Arc::new(iso_dir),
nfs_root: Arc::new(RwLock::new(None)),
local_dir_roots: Arc::new(RwLock::new(HashMap::new())),
inner: Arc::new(RwLock::new(Inner::default())),
}
}
/// v0.4.65: register the bind-mounted host path under `dir_id` so
/// `iso_path_for` can resolve `IsoSource::LocalDir` entries. Called
/// by `LocalDirManager` when a directory is added or reloaded from
/// persisted state.
pub fn register_local_dir(&self, dir_id: String, path: PathBuf) {
self.local_dir_roots.write().insert(dir_id, path);
}
/// v0.4.65: drop the path mapping for `dir_id`. Existing
/// `IsoSource::LocalDir` entries referencing this id will start
/// resolving to `None` from `iso_path_for`.
pub fn unregister_local_dir(&self, dir_id: &str) {
self.local_dir_roots.write().remove(dir_id);
}
/// Tell the store where NFS mounts live. Without this set,
/// `IsoSource::Nfs` entries cannot be resolved to a file path.
pub fn set_nfs_root(&self, root: PathBuf) {
@@ -331,19 +297,6 @@ impl IsoStore {
let root = self.nfs_root.read().clone()?;
root.join(mount_id).join(relative_path)
}
// v0.4.65: bind-mounted host directory. We look the dir_id
// up in local_dir_roots which is maintained by
// LocalDirManager. If LocalDirManager hasn't loaded yet (or
// the operator removed the directory) the resolution
// returns None and the HTTP handler 404s, same as a missing
// NFS mount.
IsoSource::LocalDir {
dir_id,
relative_path,
} => {
let root = self.local_dir_roots.read().get(dir_id).cloned()?;
root.join(relative_path)
}
};
if path.exists() {
Some(path)
@@ -409,16 +362,6 @@ impl IsoStore {
);
}
/// v0.4.65: drop every entry that belongs to a registered local
/// directory. Used by `LocalDirManager` when an operator removes a
/// directory or before re-scanning to clean out stale entries.
pub fn drop_local_dir_source(&self, dir_id: &str) {
let mut g = self.inner.write();
g.isos.retain(
|_, m| !matches!(&m.source, IsoSource::LocalDir { dir_id: did, .. } if did == dir_id),
);
}
/// Set or clear an ISO's boot password.
///
/// `Some("plaintext")` hashes via bcrypt (cost 10 — fast enough for