Skip to content

Commit 94bbeba

Browse files
committed
fix: respect cvmfs alien and localcache are now fully configurable
1 parent dff54dc commit 94bbeba

File tree

4 files changed

+97
-21
lines changed

4 files changed

+97
-21
lines changed

.github/workflows/ci-test-go.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: ci-test-golang
2+
on:
3+
push:
4+
branches:
5+
- "*"
6+
pull_request:
7+
branches:
8+
- "master"
9+
# Allows for manual triggers using the `gh` CLI.
10+
workflow_dispatch:
11+
env:
12+
GO_VERSION: "1.22"
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version: ${{ env.GO_VERSION }}
23+
24+
- name: Install dependencies
25+
run: go mod download
26+
27+
- name: Run go vet
28+
run: go vet ./...
29+
30+
- name: Run go test
31+
run: go test ./... -json > test-results.json
32+
33+
- name: Publish test results
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: go-results
37+
path: test-results.json
38+
39+
lint:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Setup Go
44+
uses: actions/setup-go@v5
45+
with:
46+
go-version: ${{ env.GO_VERSION }}
47+
48+
- name: Verify go mod tidy has been run
49+
run: |
50+
set -e
51+
go mod tidy
52+
if [ ! -z "$(git status --porcelain go.mod go.sum)" ]; then
53+
>&2 echo "Running go mod tidy modified go.mod and/or go.sum"
54+
exit 1
55+
fi
56+
57+
- name: Verify gofumpt has been run
58+
run: |
59+
set -e
60+
go install mvdan.cc/gofumpt@latest
61+
gofumpt -l -w .
62+
if [ ! -z "$(git status --porcelain .)" ]; then
63+
>&2 echo "Running gofumpt modified source code"
64+
exit 1
65+
fi

deployments/helm/cvmfs-csi/templates/nodeplugin-daemonset.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ spec:
121121
mountPath: /cvmfs
122122
mountPropagation: Bidirectional
123123
- name: cvmfs-localcache
124-
mountPath: /cvmfs-localcache
124+
mountPath: {{ .Values.cache.local.location }}
125125
{{- if .Values.cache.alien.enabled }}
126126
- name: cvmfs-aliencache
127-
mountPath: /cvmfs-aliencache
127+
mountPath: {{ .Values.cache.alien.location }}
128128
{{- end }}
129129
{{- with .Values.nodeplugin.automount.extraVolumeMounts }}
130130
{{- toYaml . | nindent 12 }}
@@ -149,7 +149,7 @@ spec:
149149
mountPath: /cvmfs
150150
mountPropagation: Bidirectional
151151
- name: cvmfs-localcache
152-
mountPath: /cvmfs-localcache
152+
mountPath: {{ .Values.cache.local.location }}
153153
{{- with .Values.nodeplugin.automountReconciler.extraVolumeMounts }}
154154
{{- toYaml . | nindent 12 }}
155155
{{- end }}

deployments/helm/cvmfs-csi/values.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ extraConfigMaps:
1313
CVMFS_USE_GEOAPI=yes
1414
CVMFS_HTTP_PROXY="http://ca-proxy.cern.ch:3128"
1515
16-
# It is advised to change these configs in the cache section of the helm values
17-
# and leave them unchanged here, so they auto-generate.
16+
# It is advised to change these configurations in the cache section of
17+
# the helm values and leave them unchanged here, so they auto-generate.
1818
CVMFS_QUOTA_LIMIT={{ .Values.cache.local.cvmfsQuotaLimit }}
19-
CVMFS_CACHE_BASE=/cvmfs-localcache
19+
CVMFS_CACHE_BASE={{ .Values.cache.local.location }}
2020
2121
{{- if .Values.cache.alien.enabled }}
22-
CVMFS_ALIEN_CACHE=/cvmfs-aliencache
22+
CVMFS_ALIEN_CACHE={{ .Values.cache.alien.location }}
2323
# When alien cache is used, CVMFS does not control the size of the cache.
2424
CVMFS_QUOTA_LIMIT=-1
2525
# Whether repositories should share a cache directory or each have their own.
@@ -46,6 +46,7 @@ extraConfigMaps:
4646
# https://cvmfs.readthedocs.io/en/stable/cpt-configure.html#alien-cache
4747
cache:
4848
local:
49+
location: /cvmfs-localcache
4950
volumeSpec:
5051
hostPath:
5152
path: /var/lib/cvmfs.csi.cern.ch/cache
@@ -55,6 +56,7 @@ cache:
5556
cvmfsQuotaLimit: 1000
5657
alien:
5758
enabled: false
59+
location: /cvmfs-aliencache
5860
volumeSpec:
5961
persistentVolumeClaim:
6062
claimName: cvmfs-alien-cache

internal/cvmfs/automount/automount.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ import (
3434

3535
const (
3636
AutofsCvmfsRoot = "/cvmfs"
37-
AlienCachePath = "/cvmfs-aliencache"
38-
LocalCachePath = "/cvmfs-localcache"
37+
38+
// Default Location of alien cache if not otherwise specified in
39+
// default.local cvmfs configuration.
40+
DefaultAlienCachePath = "/cvmfs-aliencache"
41+
42+
// Default Location of local cache if not otherwise specified in
43+
// default.local cvmfs configuration.
44+
DefaultLocalCachePath = "/cvmfs-localcache"
3945
)
4046

4147
type Opts struct {
@@ -152,27 +158,30 @@ func readEffectiveDefaultCvmfsConfig() (map[string]string, error) {
152158
}
153159

154160
func setupCvmfs(o *Opts) error {
155-
if o.HasAlienCache {
156-
// Make sure the volume is writable by CVMFS processes.
157-
if err := os.Chmod(AlienCachePath, 0o777); err != nil {
158-
return err
159-
}
160-
}
161-
162-
// Clean up local cache. It may be dirty after previous nodeplugin Pod runs.
163-
164-
log.Debugf("Cleaning up local cache directory %s...", LocalCachePath)
165-
166161
cvmfsConfig, err := readEffectiveDefaultCvmfsConfig()
167162
if err != nil {
168163
return fmt.Errorf("failed to read CVMFS config: %v", err)
169164
}
170165

166+
if o.HasAlienCache {
167+
alienCache := cvmfsConfig["CVMFS_ALIEN_CACHE"]
168+
if alienCache == "" {
169+
alienCache = DefaultAlienCachePath
170+
}
171+
// Make sure the volume is writeable by CVMFS processes.
172+
if err := os.Chmod(DefaultAlienCachePath, 0o777); err != nil {
173+
return err
174+
}
175+
}
176+
171177
cacheDir := cvmfsConfig["CVMFS_CACHE_BASE"]
172178
if cacheDir == "" {
173-
cacheDir = LocalCachePath
179+
cacheDir = DefaultLocalCachePath
174180
}
175181

182+
// Clean up local cache. It may be dirty after previous nodeplugin Pod runs.
183+
log.Debugf("Cleaning up local cache directory %s...", cacheDir)
184+
176185
if err := removeDirContents(cacheDir); err != nil {
177186
return fmt.Errorf("failed to clean up local cache directory %s: %v", cacheDir, err)
178187
}

0 commit comments

Comments
 (0)