From 1f994eeb4d3c5607f360b13ceb5e1e6a48954369 Mon Sep 17 00:00:00 2001 From: 1602077 <62025739+1602077@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:46:49 +0200 Subject: [PATCH 1/5] fix: respect cvmfs alien and localcache are now fully configurable --- .github/workflows/ci-test-go.yaml | 65 +++++++++ .../templates/nodeplugin-daemonset.yaml | 6 +- deployments/helm/cvmfs-csi/values.yaml | 10 +- go.mod | 38 +++--- go.sum | 129 ++++++++---------- internal/cvmfs/automount/automount.go | 37 +++-- 6 files changed, 176 insertions(+), 109 deletions(-) create mode 100644 .github/workflows/ci-test-go.yaml diff --git a/.github/workflows/ci-test-go.yaml b/.github/workflows/ci-test-go.yaml new file mode 100644 index 00000000..c2916c1c --- /dev/null +++ b/.github/workflows/ci-test-go.yaml @@ -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 diff --git a/deployments/helm/cvmfs-csi/templates/nodeplugin-daemonset.yaml b/deployments/helm/cvmfs-csi/templates/nodeplugin-daemonset.yaml index a28bf0ee..54b8bc12 100644 --- a/deployments/helm/cvmfs-csi/templates/nodeplugin-daemonset.yaml +++ b/deployments/helm/cvmfs-csi/templates/nodeplugin-daemonset.yaml @@ -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 }} @@ -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 }} diff --git a/deployments/helm/cvmfs-csi/values.yaml b/deployments/helm/cvmfs-csi/values.yaml index 30c17104..a1cb1aff 100644 --- a/deployments/helm/cvmfs-csi/values.yaml +++ b/deployments/helm/cvmfs-csi/values.yaml @@ -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. @@ -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 @@ -55,6 +56,7 @@ cache: cvmfsQuotaLimit: 1000 alien: enabled: false + location: /cvmfs-aliencache volumeSpec: persistentVolumeClaim: claimName: cvmfs-alien-cache diff --git a/go.mod b/go.mod index 0a3cb2c9..0d5896e1 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index c6441f9c..643d4071 100644 --- a/go.sum +++ b/go.sum @@ -1,74 +1,61 @@ -github.com/container-storage-interface/spec v1.8.0 h1:D0vhF3PLIZwlwZEf2eNbpujGCNwspwTYf2idJRJx4xI= -github.com/container-storage-interface/spec v1.8.0/go.mod h1:ROLik+GhPslwwWRNFF1KasPzroNARibH2rfz1rkg4H0= -github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY= -github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/container-storage-interface/spec v1.10.0 h1:YkzWPV39x+ZMTa6Ax2czJLLwpryrQ+dPesB34mrRMXA= +github.com/container-storage-interface/spec v1.10.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/kubernetes-csi/csi-lib-utils v0.13.0 h1:QrTdZVZbHlaSUBN9ReayBPnnF1N0edFIpUKBwVIBW3w= -github.com/kubernetes-csi/csi-lib-utils v0.13.0/go.mod h1:JS9eDIZmSjx4F9o0bLTVK/qfhIIOifdjEfVXzxWapfE= -github.com/kubernetes-csi/csi-lib-utils v0.17.0 h1:xEpJ3WYgMyyYF6fvcKHh4cDRtknuTkBS9rG8bYoLTCU= -github.com/kubernetes-csi/csi-lib-utils v0.17.0/go.mod h1:2Ba5/aQgUjbpqyC2uCcFwMF3rnPVs5jhZXm8jAzcT9Q= -github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= -github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= -github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g= -github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 h1:DujSIu+2tC9Ht0aPNA7jgj23Iq8Ewi5sgkQ++wdvonE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= -google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= -google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/kubernetes-csi/csi-lib-utils v0.19.0 h1:3sT8mL9+St2acyrEtuR7CQ5L78GR4lgsb+sfon9tGfA= +github.com/kubernetes-csi/csi-lib-utils v0.19.0/go.mod h1:lBuMKvoyd8c3EG+itmnVWApLDHnLkU7ibxxZSPuOw0M= +github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg= +github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4= +github.com/opencontainers/runc v1.1.14 h1:rgSuzbmgz5DUJjeSnw337TxDbRuqjs6iqQck/2weR6w= +github.com/opencontainers/runc v1.1.14/go.mod h1:E4C2z+7BxR7GHXp0hAY53mek+x49X1LjPNeMTfRGvOA= +github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= +github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= +golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -k8s.io/apimachinery v0.26.3 h1:dQx6PNETJ7nODU3XPtrwkfuubs6w7sX0M8n61zHIV/k= -k8s.io/apimachinery v0.26.3/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= -k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= -k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/mount-utils v0.26.3 h1:FxMDiPLCkrYgonfSaKHWltLNkyTg3Q/Xrwn94uwhd8k= -k8s.io/mount-utils v0.26.3/go.mod h1:95yx9K6N37y8YZ0/lUh9U6ITosMODNaW0/v4wvaa0Xw= -k8s.io/mount-utils v0.30.0 h1:EceYTNYVabfpdtIAHC4KgMzoZkm1B8ovZ1J666mYZQI= -k8s.io/mount-utils v0.30.0/go.mod h1:9sCVmwGLcV1MPvbZ+rToMDnl1QcGozy+jBPd0MsQLIo= -k8s.io/utils v0.0.0-20221107191617-1a15be271d1d h1:0Smp/HP1OH4Rvhe+4B8nWGERtlqAGSftbSbbmm45oFs= -k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -k8s.io/utils v0.0.0-20240423183400-0849a56e8f22 h1:ao5hUqGhsqdm+bYbjH/pRkCs0unBGe9UyDahzs9zQzQ= -k8s.io/utils v0.0.0-20240423183400-0849a56e8f22/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= +k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/mount-utils v0.31.1 h1:f8UrH9kRynljmdNGM6BaCvFUON5ZPKDgE+ltmYqI4wA= +k8s.io/mount-utils v0.31.1/go.mod h1:HV/VYBUGqYUj4vt82YltzpWvgv8FPg0G9ItyInT3NPU= +k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 h1:b2FmK8YH+QEwq/Sy2uAEhmqL5nPfGYbJOcaqjeYYZoA= +k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= diff --git a/internal/cvmfs/automount/automount.go b/internal/cvmfs/automount/automount.go index 0b495b48..6539c829 100644 --- a/internal/cvmfs/automount/automount.go +++ b/internal/cvmfs/automount/automount.go @@ -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 { @@ -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) } From a87e019a0378ad54cde852a36679aa7de8422d7f Mon Sep 17 00:00:00 2001 From: 1602077 <62025739+1602077@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:56:58 +0200 Subject: [PATCH 2/5] fix: missing embedded csi.Unimplemented*Server --- internal/cvmfs/controller/csiserver.go | 1 + internal/cvmfs/identity/csiserver.go | 1 + internal/cvmfs/node/csiserver.go | 1 + 3 files changed, 3 insertions(+) diff --git a/internal/cvmfs/controller/csiserver.go b/internal/cvmfs/controller/csiserver.go index 48b14a87..45f025ba 100644 --- a/internal/cvmfs/controller/csiserver.go +++ b/internal/cvmfs/controller/csiserver.go @@ -29,6 +29,7 @@ import ( // Server implements csi.ControllerServer interface. type Server struct { caps []*csi.ControllerServiceCapability + csi.UnimplementedControllerServer } var _ csi.ControllerServer = (*Server)(nil) diff --git a/internal/cvmfs/identity/csiserver.go b/internal/cvmfs/identity/csiserver.go index 13050654..0ca90262 100644 --- a/internal/cvmfs/identity/csiserver.go +++ b/internal/cvmfs/identity/csiserver.go @@ -28,6 +28,7 @@ import ( type Server struct { driverName string caps []*csi.PluginCapability + csi.UnimplementedIdentityServer } var _ csi.IdentityServer = (*Server)(nil) diff --git a/internal/cvmfs/node/csiserver.go b/internal/cvmfs/node/csiserver.go index 40d92565..80c00991 100644 --- a/internal/cvmfs/node/csiserver.go +++ b/internal/cvmfs/node/csiserver.go @@ -37,6 +37,7 @@ type Server struct { nodeID string singlemountRunnerEndpoint string caps []*csi.NodeServiceCapability + csi.UnimplementedNodeServer } const ( From 4f4afdbc4b9e5b074a48a0730513a1f2d396ad17 Mon Sep 17 00:00:00 2001 From: 1602077 <62025739+1602077@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:01:18 +0200 Subject: [PATCH 3/5] fix: check permisison of alienCache not DefaultAlienCachePath --- internal/cvmfs/automount/automount.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cvmfs/automount/automount.go b/internal/cvmfs/automount/automount.go index 6539c829..576c13ae 100644 --- a/internal/cvmfs/automount/automount.go +++ b/internal/cvmfs/automount/automount.go @@ -169,7 +169,7 @@ func setupCvmfs(o *Opts) error { alienCache = DefaultAlienCachePath } // Make sure the volume is writeable by CVMFS processes. - if err := os.Chmod(DefaultAlienCachePath, 0o777); err != nil { + if err := os.Chmod(alienCache, 0o777); err != nil { return err } } From e4b6408cb9687b68b83c31580819f73ec1462566 Mon Sep 17 00:00:00 2001 From: 1602077 <62025739+1602077@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:53:43 +0200 Subject: [PATCH 4/5] build: add script to make testing easier --- Makefile | 12 ++++++++---- scripts/test-build.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100755 scripts/test-build.sh diff --git a/Makefile b/Makefile index dc2bf4b4..71a8dd0e 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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} @@ -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 @@ -80,7 +83,7 @@ all: build # ------------------------------------------------------------------------------ # build -build: TARGETS = $(LOCAL_TARGET) +# build: TARGETS = $(LOCAL_TARGET) build: build-cross $(BINDIR)/csi-cvmfsplugin: $(SRC) @@ -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 . # ------------------------------------------------------------------------------ diff --git a/scripts/test-build.sh b/scripts/test-build.sh new file mode 100755 index 00000000..91f09c57 --- /dev/null +++ b/scripts/test-build.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Creates a test build of image and installs this to a cluster. +# +# This aims to make it easier to imperatively test builds when developing +# locally without require updating all the image repository paths in +# the helm chart values file. +# +# Usage: BASE_REPOSITORY=your-registry IMAGE_BUILD_TOOL=docker TARGETS=linux/amd64 IMAGE_ADDITIONAL_ARGS="--platform linux/amd64" ./test-build.sh + +set -xeoa pipefail + +BASE_REPOSITORY=${BASE_REPOSITORY} +IMAGE_BUILD_TOOL=${IMAGE_BUILD_TOOL:=docker} +IMAGE_ADDITIONAL_ARGS=${IMAGE_ADDITIONAL_ARGS} +TARGETS=${TARGETS:=linux/amd64} + +GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +IMAGE_TAG=${GIT_BRANCH//\//-} + +BASE_REPOSITORY=$BASE_REPOSITORY \ + IMAGE_ADDITIONAL_ARGS=$IMAGE_ADDITIONAL_ARGS \ + IMAGE_BUILD_TOOL=$IMAGE_BUILD_TOOL \ + TARGETS=$TARGETS \ + make image +docker push $BASE_REPOSITORY:$IMAGE_TAG + +helm install -n cvmfs-csi --create-namespace \ + cvmfs-csi \ + ./deployments/helm/cvmfs-csi/ \ + --set controllerplugin.plugin.image.repository=$BASE_REPOSITORY \ + --set controllerplugin.plugin.image.tag=$IMAGE_TAG \ + --set nodeplugin.plugin.image.repository=$BASE_REPOSITORY \ + --set nodeplugin.plugin.image.tag=$IMAGE_TAG \ + --set nodeplugin.automount.image.repository=$BASE_REPOSITORY \ + --set nodeplugin.automount.image.tag=$IMAGE_TAG \ + --set nodeplugin.automountReconciler.image.repository=$BASE_REPOSITORY \ + --set nodeplugin.automountReconciler.image.tag=$IMAGE_TAG \ + --set nodeplugin.prefetcher.image.repository=$BASE_REPOSITORY \ + --set nodeplugin.prefetcher.image.tag=$IMAGE_TAG \ + --set nodeplugin.singlemount.image.repository=$BASE_REPOSITORY \ + --set nodeplugin.singlemount.image.tag=$IMAGE_TAG From 4fe3d5b03bdecac5583e25dd06c3496e23bf9a3b Mon Sep 17 00:00:00 2001 From: 1602077 <62025739+1602077@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:45:00 +0200 Subject: [PATCH 5/5] docs: update helm README to include options for cache location --- deployments/helm/README.md | 4 ++++ scripts/test-build.sh | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/deployments/helm/README.md b/deployments/helm/README.md index aee17ef8..03d4aee9 100644 --- a/deployments/helm/README.md +++ b/deployments/helm/README.md @@ -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 @@ -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. | diff --git a/scripts/test-build.sh b/scripts/test-build.sh index 91f09c57..3e5e3d00 100755 --- a/scripts/test-build.sh +++ b/scripts/test-build.sh @@ -24,7 +24,7 @@ BASE_REPOSITORY=$BASE_REPOSITORY \ make image docker push $BASE_REPOSITORY:$IMAGE_TAG -helm install -n cvmfs-csi --create-namespace \ +helm install -n kube-system \ cvmfs-csi \ ./deployments/helm/cvmfs-csi/ \ --set controllerplugin.plugin.image.repository=$BASE_REPOSITORY \ @@ -38,4 +38,5 @@ helm install -n cvmfs-csi --create-namespace \ --set nodeplugin.prefetcher.image.repository=$BASE_REPOSITORY \ --set nodeplugin.prefetcher.image.tag=$IMAGE_TAG \ --set nodeplugin.singlemount.image.repository=$BASE_REPOSITORY \ - --set nodeplugin.singlemount.image.tag=$IMAGE_TAG + --set nodeplugin.singlemount.image.tag=$IMAGE_TAG \ + --set automountStorageClass.create=true