Utilize shared nix volume #26
Labels
No labels
blocked
bug
duplicate
effort
high
effort
low
effort
medium
effort
minimal
enhancement
help wanted
invalid
pr
feedback
pr
reviewing
question
status
backlog
status
document
status
done
status
implement
status
pending
status
planning
status
reviewing
waiting
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
tepichord/milner#26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Naina:
Overview
Add a
nixStorageClass whose claims all resolve to one directory on the durable data disk (/var/mnt/data/nix/shared), so any pod in any namespace can mount a pre-populated Nix store at/nixby declaring a PVC of classnix.local-path-provisionernormally gives every claim a private directory, so the class uses a constantpathPatternplus theallowUnsafePathPatternannotation to alias them together.12Retainis mandatory —Deletewouldrm -rfthe shared store — and populating it is a documented one-off runbook, not Terraform state.3Technical Approach
nixclass tostorage/values.yaml— constant path,Retain, non-default:45profile installleaves GC roots so the paths survive collection:7storage/tests/plan.tftest.hcl:89storage/README.mdclass table,ARCHITECTURE.mdstorage-tier note,OPERATIONS.md§8a table + §8e backup exclusion + new §8g runbook.101112Implementation Details
storage/values.yaml,storage/tests/plan.tftest.hcl,storage/README.md,ARCHITECTURE.md,OPERATIONS.md.131415worker//data/changes — the existing 100 GiB data disk backs this.1617parameters/reclaimPolicyare immutable → add a new class, never editpersistent/ephemeral;Retainis load-bearing (Delete callsrm -rf $VOL_DIR); capacity requests are ignored, so the store shares the data disk's capacity pool withpersistentPVCs.181920UserVolumeConfigsize bands reworked),nix-snapshotter/nix-csi/containix(runtime-layer, need patched containerd), a Terraform-managed population Job, and per-namespace store isolation.2122Acceptance Criteria
terraform -chdir=storage testpasses withrun "nix_class_is_one_shared_directory"asserting the constantpathPattern, theallowUnsafePathPatternannotation,Retain, and/var/mnt/data/nix.python -m pytest tests/ -vpasses (terraform fmt -checkand the storage plan test).storage/README.md,ARCHITECTURE.md, andOPERATIONS.mddocument thenixclass, a cross-namespace consumption snippet, and the population runbook./var/mnt/data/nix/as reproducible from the cache, alongside/var/mnt/data/ephemeral/.Testing Plan
terraform -chdir=storage test: newrun "nix_class_is_one_shared_directory"block above.python -m pytest tests/ -v: existing offline suite covering fmt + storage plan test.nix-storePVCs in two namespaces, write a marker file from a pod in one, read it from the other → same directory;ls /var/mnt/data/nix/shared/store.ls /nix/store | headfrom a consumer pod.Related Issues/PRs
Research Findings
local-path-provisioneralways joins the base path with a per-claimfolderName, so sharing requires one directory aliased by every claim.23pathPatternnormally must start with{{ .PVC.Namespace }}/{{ .PVC.Name }}/; settingallowUnsafePathPatternbypasses that check, and v0.0.37 reads it from a StorageClass annotation because the chart does not expose it as a parameter.2425nix-collect-garbageon the shared store.26volumeType: directorylives on the EPHEMERAL partition27 and is wiped on re-image unverified, so the durable route is a directory on the data disk, which this plan uses.UserVolumeConfigsize bands (20 GiB and 100 GiB both match>= 40 GiB), so it is avoided.28nixos/nixpublishes alinux/arm64image, matching this aarch64-only cluster.29Pre-Mortem
The
allowUnsafePathPatternannotation is never actually applied, so the constantpathPatternnever aliases the claims together. Chart v0.0.37 exposesstorageClassConfigsparameters but not arbitrary StorageClass annotations, so the class either loses the annotation (and provisioning rejects apathPatternthat does not start with{{ .PVC.Namespace }}/{{ .PVC.Name }}/) or silently provisions per-claim directories. Becauseplan.tftest.hclasserts only the Helm values object and not live provisioning, this only surfaces on the cluster when two namespaces turn out to hold different data.The store is shared and readable, but pods cannot actually run Nix against it. Mounting
/nixreadOnly: trueleaves no writable/nix/var/nix/{profiles,gcroots,temproots}or unlocked store DB, sonix develop/nix buildfail even though thels /nix/storesmoke test passes; the plan never assigns an owner for population versus normal use. The result is a mounted-but-unusable store, not the "any pod can utilize the Nix store" outcome the issue asks for.The new plan assertion does not hold in the offline
terraform testharness.yamldecode(helm_release.local_path_provisioner.values[0])depends on thevaluesargument being known at plan time and being a single-element list, which the mock-provider/offline suite used bypytestmay not guarantee, so the acceptance criterion turns the suite red before the class can be merged. Any fallback of weakening the assertion would then remove the only automated guard on theRetain/constant-path contract.