Skip to content

Commit

Permalink
fix: propagation of cvmfs alien and local cache (#150)
Browse files Browse the repository at this point in the history
* fix: respect cvmfs alien and localcache are now fully configurable
* fix: missing embedded csi.Unimplemented*Server
* build: add script to make testing easier
* docs: update helm README to include options for cache location
  • Loading branch information
1602077 authored Sep 17, 2024
1 parent dff54dc commit 539ef58
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 113 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/ci-test-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: ci-test-golang
on:
push:
branches:
- "*"
pull_request:
branches:
- "master"
# Allows for manual triggers using the `gh` CLI.
workflow_dispatch:
env:
GO_VERSION: "1.22"

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install dependencies
run: go mod download

- name: Run go vet
run: go vet ./...

- name: Run go test
run: go test ./... -json > test-results.json

- name: Publish test results
uses: actions/upload-artifact@v4
with:
name: go-results
path: test-results.json

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Verify go mod tidy has been run
run: |
set -e
go mod tidy
if [ ! -z "$(git status --porcelain go.mod go.sum)" ]; then
>&2 echo "Running go mod tidy modified go.mod and/or go.sum"
exit 1
fi
- name: Verify gofumpt has been run
run: |
set -e
go install mvdan.cc/gofumpt@latest
gofumpt -l -w .
if [ ! -z "$(git status --porcelain .)" ]; then
>&2 echo "Running gofumpt modified source code"
exit 1
fi
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ BINDIR := $(CURDIR)/bin
DIST_DIRS := find * -type d -exec
TARGETS ?= linux/amd64 linux/arm64
IMAGE_BUILD_TOOL ?= podman
IMAGE_ADDITIONAL_ARGS ?=
GOX_PARALLEL ?= 3

GOPATH = $(shell go env GOPATH)
Expand Down Expand Up @@ -50,6 +51,7 @@ endif
BINARY_VERSION ?= ${GIT_TAG}

BASE_PKG = github.com/cvmfs-contrib/cvmfs-csi
BASE_REPOSITORY ?= registry.cern.ch/kubernetes/cvmfs-csi
# Only set Version if building a tag or VERSION is set
ifneq ($(BINARY_VERSION),)
LDFLAGS += -X ${BASE_PKG}/internal/version.version=${BINARY_VERSION}
Expand All @@ -62,7 +64,8 @@ endif
LDFLAGS += -X ${BASE_PKG}/internal/version.commit=${GIT_COMMIT}
LDFLAGS += -X ${BASE_PKG}/internal/version.treestate=${GIT_DIRTY}

IMAGE_TAG := ${GIT_BRANCH}
# Replaces all "/" in git branch name with "-": docker tags can not contain a "/".
IMAGE_TAG := $(shell echo $(GIT_BRANCH) | sed 's/\//-/g')
ifneq ($(GIT_TAG),)
IMAGE_TAG = ${GIT_TAG}
endif
Expand All @@ -80,7 +83,7 @@ all: build
# ------------------------------------------------------------------------------
# build

build: TARGETS = $(LOCAL_TARGET)
# build: TARGETS = $(LOCAL_TARGET)
build: build-cross

$(BINDIR)/csi-cvmfsplugin: $(SRC)
Expand All @@ -107,11 +110,12 @@ build-cross: $(GOX) $(SRC)
# image

image: build
$(IMAGE_BUILD_TOOL) build \
$(IMAGE_BUILD_TOOL) build \
--build-arg RELEASE=$(IMAGE_TAG) \
--build-arg GITREF=$(GIT_COMMIT) \
--build-arg CREATED=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t registry.cern.ch/kubernetes/cvmfs-csi:$(IMAGE_TAG) \
$(IMAGE_ADDITIONAL_ARGS) \
-t $(BASE_REPOSITORY):$(IMAGE_TAG) \
-f ./deployments/docker/Dockerfile .

# ------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions deployments/helm/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# cvmfs-csi

A Helm chart for the CVMFS-CSI driver, allowing the mounting of CVMFS repositories in Kubernetes environments. This chart will deploy the CSI driver as a DaemonSet, thus automatically scaling the driver on each cluster node.

## Usage
Expand Down Expand Up @@ -47,9 +49,11 @@ Alternatively, a YAML file that specifies the values of the parameters can be pr
| `cvmfsConfig."config.d".use` | Whether to use this ConfigMap in /etc/cvmfs/config.d. |
| `cvmfsConfig."config.d".create` | Whether to create config.d ConfigMap. If not, and `use` is set to true, it is expected the ConfigMap is already present. |
| `cvmfsConfig."config.d".data` | config.d ConfigMap contents to use when `create` is set to true. |
| `cache.local.location` | Location of the local cvmfs cache i.e. `CVMFS_CACHE_BASE`.
| `cache.local.volumeSpec` | Volume spec for local cache. ReadWriteOnce access mode for persistent volumes is sufficient. |
| `cache.local.cvmfsQuotaLimit` | Maximum size of local cache in MiB. CVMFS client will garbage collect the exceeding amount. |
| `cache.alien.enabled` | Whether to use alien cache in deployment. |
| `cache.alien.location` | Location of the alien cvmfs cache if enabled i.e. `CVMFS_ALIEN_CACHE`.
| `cache.alien.volumeSpec` | Volume spec for local cache. ReadWriteMany access mode for persistent volumes is required. |
| `nodeplugin.name` | Component name for node plugin component. Used as `component` label value and to generate DaemonSet name. |
| `nodeplugin.plugin.image.repository` | Container image repository for CVMFS CSI node plugin. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ spec:
mountPath: /cvmfs
mountPropagation: Bidirectional
- name: cvmfs-localcache
mountPath: /cvmfs-localcache
mountPath: {{ .Values.cache.local.location }}
{{- if .Values.cache.alien.enabled }}
- name: cvmfs-aliencache
mountPath: /cvmfs-aliencache
mountPath: {{ .Values.cache.alien.location }}
{{- end }}
{{- with .Values.nodeplugin.automount.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
Expand All @@ -149,7 +149,7 @@ spec:
mountPath: /cvmfs
mountPropagation: Bidirectional
- name: cvmfs-localcache
mountPath: /cvmfs-localcache
mountPath: {{ .Values.cache.local.location }}
{{- with .Values.nodeplugin.automountReconciler.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down
10 changes: 6 additions & 4 deletions deployments/helm/cvmfs-csi/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ extraConfigMaps:
CVMFS_USE_GEOAPI=yes
CVMFS_HTTP_PROXY="http://ca-proxy.cern.ch:3128"
# It is advised to change these configs in the cache section of the helm values
# and leave them unchanged here, so they auto-generate.
# It is advised to change these configurations in the cache section of
# the helm values and leave them unchanged here, so they auto-generate.
CVMFS_QUOTA_LIMIT={{ .Values.cache.local.cvmfsQuotaLimit }}
CVMFS_CACHE_BASE=/cvmfs-localcache
CVMFS_CACHE_BASE={{ .Values.cache.local.location }}
{{- if .Values.cache.alien.enabled }}
CVMFS_ALIEN_CACHE=/cvmfs-aliencache
CVMFS_ALIEN_CACHE={{ .Values.cache.alien.location }}
# When alien cache is used, CVMFS does not control the size of the cache.
CVMFS_QUOTA_LIMIT=-1
# Whether repositories should share a cache directory or each have their own.
Expand All @@ -46,6 +46,7 @@ extraConfigMaps:
# https://cvmfs.readthedocs.io/en/stable/cpt-configure.html#alien-cache
cache:
local:
location: /cvmfs-localcache
volumeSpec:
hostPath:
path: /var/lib/cvmfs.csi.cern.ch/cache
Expand All @@ -55,6 +56,7 @@ cache:
cvmfsQuotaLimit: 1000
alien:
enabled: false
location: /cvmfs-aliencache
volumeSpec:
persistentVolumeClaim:
claimName: cvmfs-alien-cache
Expand Down
38 changes: 21 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
module github.com/cvmfs-contrib/cvmfs-csi

go 1.22.0
go 1.22.5

toolchain go1.22.2
toolchain go1.23.1

require (
github.com/container-storage-interface/spec v1.9.0
github.com/kubernetes-csi/csi-lib-utils v0.17.0
github.com/moby/sys/mountinfo v0.7.1
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.34.0
k8s.io/apimachinery v0.30.0
k8s.io/klog/v2 v2.120.1
k8s.io/mount-utils v0.30.0
github.com/container-storage-interface/spec v1.10.0
github.com/kubernetes-csi/csi-lib-utils v0.19.0
github.com/moby/sys/mountinfo v0.7.2
google.golang.org/grpc v1.66.2
google.golang.org/protobuf v1.34.2
k8s.io/apimachinery v0.31.1
k8s.io/klog/v2 v2.130.1
k8s.io/mount-utils v0.31.1
)

require (
github.com/go-logr/logr v1.4.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
k8s.io/utils v0.0.0-20240423183400-0849a56e8f22 // indirect
github.com/opencontainers/runc v1.1.14 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 // indirect
)
Loading

0 comments on commit 539ef58

Please sign in to comment.