Skip to content

Commit

Permalink
fix: respect cvmfs alien and localcache are now fully configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
1602077 committed Sep 13, 2024
1 parent dff54dc commit 94bbeba
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 21 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
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
37 changes: 23 additions & 14 deletions internal/cvmfs/automount/automount.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ import (

const (
AutofsCvmfsRoot = "/cvmfs"
AlienCachePath = "/cvmfs-aliencache"
LocalCachePath = "/cvmfs-localcache"

// Default Location of alien cache if not otherwise specified in
// default.local cvmfs configuration.
DefaultAlienCachePath = "/cvmfs-aliencache"

// Default Location of local cache if not otherwise specified in
// default.local cvmfs configuration.
DefaultLocalCachePath = "/cvmfs-localcache"
)

type Opts struct {
Expand Down Expand Up @@ -152,27 +158,30 @@ func readEffectiveDefaultCvmfsConfig() (map[string]string, error) {
}

func setupCvmfs(o *Opts) error {
if o.HasAlienCache {
// Make sure the volume is writable by CVMFS processes.
if err := os.Chmod(AlienCachePath, 0o777); err != nil {
return err
}
}

// Clean up local cache. It may be dirty after previous nodeplugin Pod runs.

log.Debugf("Cleaning up local cache directory %s...", LocalCachePath)

cvmfsConfig, err := readEffectiveDefaultCvmfsConfig()
if err != nil {
return fmt.Errorf("failed to read CVMFS config: %v", err)
}

if o.HasAlienCache {
alienCache := cvmfsConfig["CVMFS_ALIEN_CACHE"]
if alienCache == "" {
alienCache = DefaultAlienCachePath
}
// Make sure the volume is writeable by CVMFS processes.
if err := os.Chmod(DefaultAlienCachePath, 0o777); err != nil {
return err
}
}

cacheDir := cvmfsConfig["CVMFS_CACHE_BASE"]
if cacheDir == "" {
cacheDir = LocalCachePath
cacheDir = DefaultLocalCachePath
}

// Clean up local cache. It may be dirty after previous nodeplugin Pod runs.
log.Debugf("Cleaning up local cache directory %s...", cacheDir)

if err := removeDirContents(cacheDir); err != nil {
return fmt.Errorf("failed to clean up local cache directory %s: %v", cacheDir, err)
}
Expand Down

0 comments on commit 94bbeba

Please sign in to comment.