This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Scality CSI Driver for S3 — a Kubernetes CSI driver that mounts Scality RING S3 buckets
as persistent volumes using AWS Mountpoint (a FUSE-based mount-s3 binary).
Scality fork of awslabs/mountpoint-s3-csi-driver with dynamic provisioning,
RING S3 support, pod-based mounting, and a Mage build workflow.
Go module: github.com/scality/mountpoint-s3-csi-driver
CSI driver name: s3.csi.scality.com
make bin # Cross-compile Go binaries (GOOS=linux)
make container CONTAINER_TAG=local # Build Docker imagemake unit-test # Unit tests with coverage
make test # Unit tests (race detection) + CSI compliance
make csi-compliance-test # CSI sanity tests only
make controller-integration-test # Controller tests with envtest (real API server)
# Single test
go test -v ./pkg/driver/node/mounter -run TestPodMounter
# E2E (requires kind/minikube cluster + S3 backend)
S3_ENDPOINT_URL=http://s3.example.com:8000 mage e2e:allmake fmt # gofmt
make precommit # All pre-commit hooks (golangci-lint runs with GOOS=linux)
gofumpt -w . # Strict formatting (required by pre-commit)
goimports -w . # Import organization (required by pre-commit)After modifying pkg/api/v2/ types:
make generate # Regenerate CRD YAML + deepcopy methodsS3_ENDPOINT_URL=http://192.0.0.2:8000 mage up # Build image, load to cluster, install via Helm
mage status # Check installation
mage down # Uninstall + cleanup
SCALITY_CSI_VERSION=1.2.0 mage install # Install published version from OCI registryCredentials are loaded from tests/e2e/integration_config.json. Mage auto-detects kind/minikube/OpenShift and configures DNS mapping (s3.example.com → real S3 endpoint) via CoreDNS.
make docs # Build (strict) + serve MkDocs site
make docs-clean # Remove site/ build artifacts-
scality-s3-csi-driver(cmd/scality-csi-driver/) — Combined CSI node + identity + controller gRPC server. Runs as DaemonSet. HandlesNodePublishVolume/NodeUnpublishVolume. Can run controller-only withCSI_CONTROLLER_ONLY=true. -
scality-csi-controller(cmd/scality-csi-controller/) — Kubernetes operator (controller-runtime). Watches workload pods, creates/manages Mountpoint Pods andMountpointS3PodAttachmentCRDs. Runs stale attachment cleaner. -
scality-s3-csi-mounter(cmd/scality-csi-mounter/) — Entrypoint for Mountpoint Pods. Receives mount options via Unix socket, spawnsmount-s3, waits for unmount signal.
| Package | Purpose |
|---|---|
pkg/driver/ |
Core CSI driver: driver.go (setup), controller.go (CreateVolume/DeleteVolume for dynamic provisioning) |
pkg/driver/node/ |
CSI Node service: node.go (mount/unmount coordination) |
pkg/driver/node/mounter/ |
Mounter interface + PodMounter implementation (source mount + bind mount) |
pkg/driver/node/credentialprovider/ |
Credential resolution (secrets, env, driver config) |
pkg/driver/storageclass/ |
StorageClass parameter parsing for dynamic provisioning |
pkg/api/v2/ |
MountpointS3PodAttachment CRD types + field indexers |
pkg/podmounter/mppod/ |
Mountpoint Pod creation, path management, headroom pods |
pkg/podmounter/mountoptions/ |
Mount option serialization over Unix sockets |
pkg/s3client/ |
Client interface for S3 operations (CreateBucket, DeleteBucket, BucketExists) |
pkg/system/ |
Linux-specific syscalls (FUSE mount, bind mount) |
cmd/scality-csi-controller/csicontroller/ |
Reconciler, expectations system, stale attachment cleaner |
The MountpointS3PodAttachment CRD decouples controller decisions from node mount actions:
- User creates PVC → CSI external-provisioner calls
CreateVolume→ controller creates S3 bucket - Kubelet schedules workload pod → calls
NodePublishVolumeon node - Pod Reconciler (controller) detects workload pod, creates Mountpoint Pod + S3PA CRD
- Node driver waits for S3PA, finds assigned Mountpoint Pod name
- Node sends mount options to Mountpoint Pod via Unix socket →
mount-s3performs FUSE mount - Node creates bind mount from source to workload container's target path
Volume sharing: Workloads with matching (node + PV + mountOptions + fsGroup) share one Mountpoint Pod.
The reconciler (csicontroller/expectations.go) tracks pending S3PA creations in memory to handle Kubernetes eventual consistency — prevents duplicate CRD creation during informer cache lag.
| Directory | Framework | What it tests |
|---|---|---|
{cmd,pkg}/*_test.go |
go test |
Unit tests with mocked interfaces |
tests/sanity/ |
csi-test (Ginkgo) |
CSI spec compliance |
tests/controller/ |
envtest (Ginkgo/Gomega) |
Reconciler + CRD operations against real API server |
tests/e2e/ |
Ginkgo + Mage | End-to-end on real K8s + S3 (custom suites in customsuites/) |
tests/upgrade/ |
Mage | Driver version upgrade compatibility |
tests/helm/ |
Shell scripts | Helm chart validation |
Located at charts/scality-mountpoint-s3-csi-driver/. Key templates: node.yaml (DaemonSet), controller.yaml (Deployment), CRD in crds/. Validate with helm lint charts/scality-mountpoint-s3-csi-driver.
| Workflow | Purpose |
|---|---|
code-quality-tests.yaml |
Unit tests + coverage |
linting-and-formatting.yaml |
golangci-lint, pre-commit hooks |
e2e-tests.yaml |
E2E on kind |
e2e-openshift.yaml |
E2E on OpenShift |
upgrade-test.yaml |
Upgrade compatibility |
release.yaml |
Build + publish to OCI registry |
- Formatting:
gofmt+goimports+gofumpt(all three checked by pre-commit). golangci-lint runs withGOOS=linuxto include Linux-only files. - Linting config:
.golangci.yaml— enables errcheck, govet, ineffassign, staticcheck, unused. Excludestests/controllerandtests/sanity. - Commit messages:
S3CSI-XXX: Brief descriptionwith body explaining what/why, thenIssue: <ISSUE-NUMBER>. - Branch naming:
feature/S3CSI-XXX-descriptionorimprovement/S3CSI-XXX-description. - Docker image: Multi-stage build — Amazon Linux 2 for Mountpoint binary (old glibc), Go builder, EKS Distro minimal runtime.
Do not add <br/> tags in Mermaid diagrams — MkDocs does not honor them.