diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 1fc1b3d..76b5f4d 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -45,6 +45,7 @@ func main() { flag.Parse() klog.V(2).Infof("Driver version %v, GitVersion %s", csi.DriverVersion, version) + klog.V(2).Info("Driver CSI Spec version: ", csi.DriverSpecVersion) if *showVersion { klog.Infof("Driver version %v, GitVersion %s", csi.DriverVersion, version) diff --git a/cmd/node/main.go b/cmd/node/main.go index f7b1f19..69af580 100644 --- a/cmd/node/main.go +++ b/cmd/node/main.go @@ -51,9 +51,11 @@ func main() { flag.Parse() klog.V(2).Infof("Driver version %v, GitVersion %s", csi.DriverVersion, version) + klog.V(2).Info("Driver CSI Spec version: ", csi.DriverSpecVersion) if *showVersion { klog.Infof("Driver version %v, GitVersion %s", csi.DriverVersion, version) + klog.Info("Driver CSI Spec version: ", csi.DriverSpecVersion) os.Exit(0) } diff --git a/docker-compose.yml b/docker-compose.yml index a7b8223..2e80d20 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,7 @@ services: source: ./ target: /src csi-attacher: - image: registry.k8s.io/sig-storage/csi-attacher:v4.4.0 + image: registry.k8s.io/sig-storage/csi-attacher:v4.4.3 network_mode: "service:base" command: - "--v=5" @@ -40,7 +40,7 @@ services: source: ./hack target: /etc/kubernetes csi-resizer: - image: registry.k8s.io/sig-storage/csi-resizer:v1.9.0 + image: registry.k8s.io/sig-storage/csi-resizer:v1.9.3 network_mode: "service:base" command: - "--v=5" @@ -56,7 +56,7 @@ services: source: ./hack target: /etc/kubernetes csi-provisioner: - image: registry.k8s.io/sig-storage/csi-provisioner:v3.6.0 + image: registry.k8s.io/sig-storage/csi-provisioner:v3.6.3 network_mode: "service:base" command: - "--v=5" @@ -81,7 +81,7 @@ services: source: ./hack target: /etc/kubernetes # csi-node-driver-registrar: - # image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.7.0 + # image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.9.3 # network_mode: "service:base" # command: # - "--v=5" diff --git a/docs/deploy/test-statefulset-raw.yaml b/docs/deploy/test-statefulset-raw.yaml new file mode 100644 index 0000000..be87602 --- /dev/null +++ b/docs/deploy/test-statefulset-raw.yaml @@ -0,0 +1,56 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test + namespace: default + labels: + app: alpine +spec: + podManagementPolicy: Parallel # default is OrderedReady + serviceName: test + replicas: 1 + template: + metadata: + labels: + app: alpine + spec: + terminationGracePeriodSeconds: 3 + tolerations: + - effect: NoSchedule + key: node-role.kubernetes.io/control-plane + nodeSelector: + # kubernetes.io/hostname: kube-21 + # topology.kubernetes.io/zone: hvm-1 + containers: + - name: alpine + image: alpine + command: ["sleep","1d"] + securityContext: + privileged: true + capabilities: + drop: + - ALL + add: + - SYS_ADMIN + - CHOWN + - DAC_OVERRIDE + seccompProfile: + type: RuntimeDefault + volumeDevices: + - name: storage + devicePath: /dev/xvda + updateStrategy: + type: RollingUpdate + selector: + matchLabels: + app: alpine + volumeClaimTemplates: + - metadata: + name: storage + spec: + accessModes: ["ReadWriteOnce"] + volumeMode: Block + resources: + requests: + storage: 1Gi + storageClassName: proxmox-zfs diff --git a/go.mod b/go.mod index 7681376..f8bd8a9 100644 --- a/go.mod +++ b/go.mod @@ -3,38 +3,37 @@ module github.com/sergelogvinov/proxmox-csi-plugin go 1.21 require ( - github.com/Telmate/proxmox-api-go v0.0.0-20231221094250-f5ef0e701d88 - github.com/container-storage-interface/spec v1.8.0 + github.com/Telmate/proxmox-api-go v0.0.0-20240102094143-0b0c911a0a51 + github.com/container-storage-interface/spec v1.9.0 github.com/golang/protobuf v1.5.3 github.com/jarcoal/httpmock v1.3.1 - github.com/kubernetes-csi/csi-lib-utils v0.16.0 - github.com/sergelogvinov/proxmox-cloud-controller-manager v0.2.0 + github.com/kubernetes-csi/csi-lib-utils v0.17.0 + github.com/sergelogvinov/proxmox-cloud-controller-manager v0.3.0 github.com/siderolabs/go-blockdevice v0.4.7 github.com/stretchr/testify v1.8.4 - google.golang.org/grpc v1.59.0 - k8s.io/api v0.28.5 - k8s.io/apimachinery v0.28.5 - k8s.io/client-go v0.28.5 + google.golang.org/grpc v1.60.1 + k8s.io/api v0.29.0 + k8s.io/apimachinery v0.29.0 + k8s.io/client-go v0.29.0 k8s.io/cloud-provider-openstack v1.28.1 k8s.io/klog/v2 v2.110.1 - k8s.io/mount-utils v0.28.5 - k8s.io/utils v0.0.0-20231127182322-b307cd553661 + k8s.io/mount-utils v0.29.0 + k8s.io/utils v0.0.0-20240102154912-e7106e64919e ) require ( github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.10.2 // indirect - github.com/evanphx/json-patch v5.6.0+incompatible // indirect - github.com/go-logr/logr v1.3.0 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/emicklei/go-restful/v3 v3.11.1 // indirect + github.com/evanphx/json-patch v5.7.0+incompatible // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-openapi/jsonpointer v0.20.2 // indirect + github.com/go-openapi/jsonreference v0.20.4 // indirect + github.com/go-openapi/swag v0.22.7 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.5.9 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -48,21 +47,21 @@ require ( github.com/siderolabs/go-cmd v0.1.1 // indirect github.com/siderolabs/go-retry v0.3.2 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.1 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.4.0 // indirect + golang.org/x/time v0.5.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect + k8s.io/kube-openapi v0.0.0-20240103160808-8a9faedaf1cd // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index ad10b68..77cd73b 100644 --- a/go.sum +++ b/go.sum @@ -1,25 +1,25 @@ -github.com/Telmate/proxmox-api-go v0.0.0-20231221094250-f5ef0e701d88 h1:kMzm0HTXio9gouQ60wP6iifmP9lZuoStlXajq6VSsc0= -github.com/Telmate/proxmox-api-go v0.0.0-20231221094250-f5ef0e701d88/go.mod h1:xOwyTd8uC2IiYfmjwCVU2fTTVToFCm9yxJzn4cd7rPw= +github.com/Telmate/proxmox-api-go v0.0.0-20240102094143-0b0c911a0a51 h1:Fp6xeDgxYSAf4Y0L2uWmjHkPrEdf3uONUhGwje2Agas= +github.com/Telmate/proxmox-api-go v0.0.0-20240102094143-0b0c911a0a51/go.mod h1:xOwyTd8uC2IiYfmjwCVU2fTTVToFCm9yxJzn4cd7rPw= github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 h1:7Ip0wMmLHLRJdrloDxZfhMm0xrLXZS8+COSu2bXmEQs= github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -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/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= -github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/emicklei/go-restful/v3 v3.11.1 h1:S+9bSbua1z3FgCnV0KKOSSZ3mDthb5NyEPL5gEpCvyk= +github.com/emicklei/go-restful/v3 v3.11.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= +github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= +github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= +github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= +github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= +github.com/go-openapi/swag v0.22.7 h1:JWrc1uc/P9cSomxfnsFSVWoE1FW6bNbrVPmpQYpCcR8= +github.com/go-openapi/swag v0.22.7/go.mod h1:Gl91UqO+btAM0plGGxHqJcQZ1ZTy6jbmridBTsDy8A0= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -31,15 +31,16 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= 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/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +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/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= @@ -50,15 +51,12 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubernetes-csi/csi-lib-utils v0.16.0 h1:LXCvkhXHtFOkl7LoDqFdho/MuebccZqWxLwhKiRGiBg= -github.com/kubernetes-csi/csi-lib-utils v0.16.0/go.mod h1:fp1Oik+45tP2o4X9SD/SBWXLTQYT9wtLxGasBE3+vBI= +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/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g= @@ -72,18 +70,18 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE= -github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM= -github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= +github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/sergelogvinov/proxmox-cloud-controller-manager v0.2.0 h1:oJLqLn2ZhfFr6baU4HcdYP/ySBNOTRDFHwgzDVKt3XQ= -github.com/sergelogvinov/proxmox-cloud-controller-manager v0.2.0/go.mod h1:WTB5GHYbmgqbEh1/bb8UsoWt21fdy7+NYWZ784cOUvo= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/sergelogvinov/proxmox-cloud-controller-manager v0.3.0 h1:2TurTnjawIx5j3YIRw0PEBbxM7YpLwlVBXfnnnpYH5s= +github.com/sergelogvinov/proxmox-cloud-controller-manager v0.3.0/go.mod h1:SILDj23jkQGVPtWCWdadd3E6VDJlWnN+P4rgKGrg1j8= github.com/siderolabs/go-blockdevice v0.4.7 h1:2bk4WpEEflGxjrNwp57ye24Pr+cYgAiAeNMWiQOuWbQ= github.com/siderolabs/go-blockdevice v0.4.7/go.mod h1:4PeOuk71pReJj1JQEXDE7kIIQJPVe8a+HZQa+qjxSEA= github.com/siderolabs/go-cmd v0.1.1 h1:nTouZUSxLeiiEe7hFexSVvaTsY/3O8k1s08BxPRrsps= @@ -94,12 +92,13 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0= +github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -145,29 +144,29 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= 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/time v0.4.0 h1:Z81tqI5ddIoXDPvVQ7/7CC9TnLM7ubaFG2qXYd5BbYY= -golang.org/x/time v0.4.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= 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.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -179,25 +178,25 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.28.5 h1:XIPNr3nBgTEaCdEiwZ+dXaO9SB4NeTOZ2pNDRrFgfb4= -k8s.io/api v0.28.5/go.mod h1:98zkTCc60iSnqqCIyCB1GI7PYDiRDYTSfL0PRIxpM4c= -k8s.io/apimachinery v0.28.5 h1:EEj2q1qdTcv2p5wl88KavAn3VlFRjREgRu8Sm/EuMPY= -k8s.io/apimachinery v0.28.5/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= -k8s.io/client-go v0.28.5 h1:6UNmc33vuJhh3+SAOEKku3QnKa+DtPKGnhO2MR0IEbk= -k8s.io/client-go v0.28.5/go.mod h1:+pt086yx1i0HAlHzM9S+RZQDqdlzuXFl4hY01uhpcpA= +k8s.io/api v0.29.0 h1:NiCdQMY1QOp1H8lfRyeEf8eOwV6+0xA6XEE44ohDX2A= +k8s.io/api v0.29.0/go.mod h1:sdVmXoz2Bo/cb77Pxi71IPTSErEW32xa4aXwKH7gfBA= +k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o= +k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis= +k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8= +k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38= k8s.io/cloud-provider-openstack v1.28.1 h1:wtAYz7RtccCNUrmkSDOMsRaY7sE2gD39zj/blm/MeEo= k8s.io/cloud-provider-openstack v1.28.1/go.mod h1:fVE4xuV/kptxP2AO5Izhi8d3a0lbboqMszeFk8jxx4A= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/mount-utils v0.28.5 h1:JRBnrJ3uGHMGzJlk/CqzcL6wtayAOfTqecAugYZeff4= -k8s.io/mount-utils v0.28.5/go.mod h1:ceMAZ+Nzlk8zOwN205YXXGJRGmf1o0/XIwsKnG44p0I= -k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI= -k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/kube-openapi v0.0.0-20240103160808-8a9faedaf1cd h1:mbo+LIupdi4bqfqC+C8nsyFwvSgmw4eK3yVyEGGPrmc= +k8s.io/kube-openapi v0.0.0-20240103160808-8a9faedaf1cd/go.mod h1:sIV51WBTkZrlGOJMCDZDA1IaPBUDTulPpD4y7oe038k= +k8s.io/mount-utils v0.29.0 h1:KcUE0bFHONQC10V3SuLWQ6+l8nmJggw9lKLpDftIshI= +k8s.io/mount-utils v0.29.0/go.mod h1:N3lDK/G1B8R/IkAt4NhHyqB07OqEr7P763z3TNge94U= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/pkg/csi/controller.go b/pkg/csi/controller.go index 3454c4d..4758bb6 100644 --- a/pkg/csi/controller.go +++ b/pkg/csi/controller.go @@ -532,6 +532,11 @@ func (d *ControllerService) ControllerExpandVolume(_ context.Context, request *c return nil, status.Error(codes.InvalidArgument, "VolumeID must be provided") } + volCapability := request.GetVolumeCapability() + if volCapability == nil { + return nil, status.Error(codes.InvalidArgument, "VolumeCapability must be provided") + } + capacityRange := request.GetCapacityRange() if capacityRange == nil { return nil, status.Error(codes.InvalidArgument, "CapacityRange must be provided") @@ -643,3 +648,10 @@ func (d *ControllerService) ControllerGetVolume(_ context.Context, request *csi. return nil, status.Error(codes.Unimplemented, "") } + +// ControllerModifyVolume modify a volume +func (d *ControllerService) ControllerModifyVolume(_ context.Context, request *csi.ControllerModifyVolumeRequest) (*csi.ControllerModifyVolumeResponse, error) { + klog.V(4).Infof("ControllerModifyVolume: called with args %+v", protosanitizer.StripSecrets(*request)) + + return nil, status.Error(codes.Unimplemented, "") +} diff --git a/pkg/csi/controller_test.go b/pkg/csi/controller_test.go index bd1b168..b4f2f18 100644 --- a/pkg/csi/controller_test.go +++ b/pkg/csi/controller_test.go @@ -1108,6 +1108,12 @@ func (ts *csiTestSuite) TestControllerExpandVolumeError() { LimitBytes: 150, } + volCapability := &proto.VolumeCapability{ + AccessMode: &proto.VolumeCapability_AccessMode{ + Mode: proto.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + }, + } + tests := []struct { msg string request *proto.ControllerExpandVolumeRequest @@ -1117,14 +1123,16 @@ func (ts *csiTestSuite) TestControllerExpandVolumeError() { { msg: "VolumeID", request: &proto.ControllerExpandVolumeRequest{ - CapacityRange: capRange, + CapacityRange: capRange, + VolumeCapability: volCapability, }, expectedError: status.Error(codes.InvalidArgument, "VolumeID must be provided"), }, { msg: "CapacityRange", request: &proto.ControllerExpandVolumeRequest{ - VolumeId: "volume-id", + VolumeId: "volume-id", + VolumeCapability: volCapability, }, expectedError: status.Error(codes.InvalidArgument, "CapacityRange must be provided"), }, @@ -1136,46 +1144,52 @@ func (ts *csiTestSuite) TestControllerExpandVolumeError() { RequiredBytes: 150, LimitBytes: 100, }, + VolumeCapability: volCapability, }, expectedError: status.Error(codes.OutOfRange, "after round-up, volume size exceeds the limit specified"), }, { msg: "WrongVolumeID", request: &proto.ControllerExpandVolumeRequest{ - VolumeId: "volume-id", - CapacityRange: capRange, + VolumeId: "volume-id", + CapacityRange: capRange, + VolumeCapability: volCapability, }, expectedError: status.Error(codes.InvalidArgument, "VolumeID must be in the format of region/zone/storageName/diskName"), }, { msg: "WrongCluster", request: &proto.ControllerExpandVolumeRequest{ - VolumeId: "fake-region/node/data/volume-id", - CapacityRange: capRange, + VolumeId: "fake-region/node/data/volume-id", + CapacityRange: capRange, + VolumeCapability: volCapability, }, expectedError: status.Error(codes.Internal, "proxmox cluster fake-region not found"), }, { msg: "WrongPVC", request: &proto.ControllerExpandVolumeRequest{ - VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-none", - CapacityRange: capRange, + VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-none", + CapacityRange: capRange, + VolumeCapability: volCapability, }, expected: &proto.ControllerExpandVolumeResponse{}, }, { msg: "UpublishedVolume", request: &proto.ControllerExpandVolumeRequest{ - VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-error", - CapacityRange: capRange, + VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-error", + CapacityRange: capRange, + VolumeCapability: volCapability, }, expectedError: status.Error(codes.Internal, "cannot resize unpublished volumeID"), }, { msg: "ExpandVolume", request: &proto.ControllerExpandVolumeRequest{ - VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-123", - CapacityRange: capRange, + VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-123", + CapacityRange: capRange, + VolumeCapability: volCapability, }, expected: &proto.ControllerExpandVolumeResponse{ CapacityBytes: 100, diff --git a/pkg/csi/driver.go b/pkg/csi/driver.go index 946c6a0..39c176c 100644 --- a/pkg/csi/driver.go +++ b/pkg/csi/driver.go @@ -21,7 +21,9 @@ const ( // DriverName is the name of the CSI driver DriverName = "csi.proxmox.sinextra.dev" // DriverVersion is the version of the CSI driver - DriverVersion = "0.3.0" + DriverVersion = "0.4.0" + // DriverSpecVersion CSI spec version + DriverSpecVersion = "1.8.0" // StorageIDKey is the ID of the Proxmox storage StorageIDKey = "storage" diff --git a/pkg/csi/node.go b/pkg/csi/node.go index 374320c..7ac040e 100644 --- a/pkg/csi/node.go +++ b/pkg/csi/node.go @@ -19,6 +19,8 @@ package csi import ( "context" "fmt" + "os" + "path/filepath" "strings" "github.com/container-storage-interface/spec/lib/go/csi" @@ -213,6 +215,12 @@ func (n *NodeService) NodeUnstageVolume(_ context.Context, request *csi.NodeUnst return nil, status.Error(codes.InvalidArgument, "StagingTargetPath must be provided") } + // Raw Block device is not mounted, so we can return here + // https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/csi/csi_block.go + if strings.Contains(stagingTargetPath, "/kubernetes.io/csi/volumeDevices/") { + return &csi.NodeUnstageVolumeResponse{}, nil + } + cmd := exec.New().Command("fstrim", "-v", stagingTargetPath) if out, err := cmd.CombinedOutput(); err != nil { klog.Errorf("NodeUnstageVolume: failed to trim filesystem %s: %v\n", stagingTargetPath, err) @@ -285,11 +293,37 @@ func (n *NodeService) NodePublishVolume(_ context.Context, request *csi.NodePubl mountOptions = append(mountOptions, "rw") } + m := n.Mount + if blk := volumeCapability.GetBlock(); blk != nil { - return nil, status.Error(codes.Unimplemented, "publish block volume is not supported") - } + podVolumePath := filepath.Dir(targetPath) - m := n.Mount + exists, err := utilpath.Exists(utilpath.CheckFollowSymlink, podVolumePath) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + if !exists { + if err = m.MakeDir(podVolumePath); err != nil { + return nil, status.Errorf(codes.Internal, "Could not create dir %q: %v", podVolumePath, err) + } + } + + err = m.MakeFile(targetPath) + if err != nil { + return nil, status.Errorf(codes.Internal, "Error in making file %v", err) + } + + if err := m.Mounter().Mount(devicePath, targetPath, "", mountOptions); err != nil { + if removeErr := os.Remove(targetPath); removeErr != nil { + return nil, status.Errorf(codes.Internal, "Could not remove mount target %q: %v", targetPath, err) + } + + return nil, status.Errorf(codes.Internal, "Could not mount %q at %q: %v", devicePath, targetPath, err) + } + + return &csi.NodePublishVolumeResponse{}, nil + } _, err := m.GetMountFs(stagingTargetPath) if err != nil { @@ -402,6 +436,15 @@ func (n *NodeService) NodeExpandVolume(_ context.Context, request *csi.NodeExpan return nil, status.Error(codes.InvalidArgument, "VolumePath must be provided") } + volCapability := request.GetVolumeCapability() + if volCapability == nil { + return nil, status.Error(codes.InvalidArgument, "VolumeCapability must be provided") + } + + if volCapability.GetBlock() != nil { + return &csi.NodeExpandVolumeResponse{}, nil + } + output, err := n.Mount.GetMountFs(volumePath) if err != nil { return nil, status.Error(codes.Internal, fmt.Sprintf("Failed to find mount file system %s: %v", volumePath, err)) diff --git a/pkg/csi/node_test.go b/pkg/csi/node_test.go index d56e29b..d2523fc 100644 --- a/pkg/csi/node_test.go +++ b/pkg/csi/node_test.go @@ -247,24 +247,6 @@ func TestNodeServiceNodePublishVolumeErrors(t *testing.T) { }, expectedError: fmt.Errorf("VolumeCapability not supported"), }, - { - msg: "BlockVolume", - request: &proto.NodePublishVolumeRequest{ - VolumeId: "pvc-1", - StagingTargetPath: "/staging", - TargetPath: "/target", - VolumeCapability: &proto.VolumeCapability{ - AccessMode: &proto.VolumeCapability_AccessMode{ - Mode: proto.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, - }, - AccessType: &proto.VolumeCapability_Block{ - Block: &proto.VolumeCapability_BlockVolume{}, - }, - }, - PublishContext: params, - }, - expectedError: fmt.Errorf("publish block volume is not supported"), - }, { msg: "VolumeCapability", request: &proto.NodePublishVolumeRequest{