Skip to content

Commit 20f2f6e

Browse files
Merge pull request #55 from dobsonj/rebase-v5.2.4
STOR-1408: Chore: Update ibm-vpc-block-csi-driver to the latest release
2 parents 9417a24 + c0732f5 commit 20f2f6e

27 files changed

+194
-68
lines changed

.nancy-ignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
CVE-2020-8561 ## CWE-610: Externally Controlled Reference to a Resource in Another Sphere
2-
CVE-2021-25740 ## CWE-610: Externally Controlled Reference to a Resource in Another Sphere
2+
CVE-2021-25740 ## CWE-610: Externally Controlled Reference to a Resource in Another Sphere
33
sonatype-2022-6522 ## 1 non-CVE vuln [pkg:golang/k8s.io/[email protected]]
4+
CVE-2021-25749 ## Windows workloads can run as ContainerAdministrator even when those workloads set the runAsNonRoot option to true.Fix not available in community till now.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ env:
66
- GO111MODULE=on
77

88
go:
9-
- "1.18.2"
9+
- "1.20.10"
1010

1111
before_install:
1212
- go install github.com/mattn/goveralls@latest

Dockerfile.builder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.19.6
1+
FROM golang:1.20.10
22

33
WORKDIR /go/src/github.com/kubernetes-sigs/ibm-vpc-block-csi-driver
44
ADD . /go/src/github.com/kubernetes-sigs/ibm-vpc-block-csi-driver

Dockerfile.dependencycheck

Lines changed: 0 additions & 12 deletions
This file was deleted.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ GIT_COMMIT_SHA="$(shell git rev-parse HEAD 2>/dev/null)"
2020
GIT_REMOTE_URL="$(shell git config --get remote.origin.url 2>/dev/null)"
2121
BUILD_DATE="$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")"
2222
OSS_FILES := go.mod Dockerfile
23-
GOLANG_VERSION="1.19.6"
23+
GOLANG_VERSION="1.20.10"
2424

2525

2626
STAGING_REGISTRY ?= gcr.io/k8s-staging-cloud-provider-ibm
@@ -44,7 +44,7 @@ BUILD_NUMBER?=unknown
4444
GO111MODULE_FLAG?=on
4545
export GO111MODULE=$(GO111MODULE_FLAG)
4646

47-
export LINT_VERSION="1.45.2"
47+
export LINT_VERSION="1.51.2"
4848

4949
GOFILES=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
5050

@@ -88,7 +88,7 @@ verify:
8888

8989
.PHONY: test
9090
test:
91-
go test -v -race ./cmd/... ./pkg/...
91+
go test -timeout 1800s -v -race ./cmd/... ./pkg/...
9292

9393
.PHONY: ut-coverage
9494
ut-coverage:

cmd/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ import (
2121
"flag"
2222
"strings"
2323

24-
"math/rand"
2524
"net/http"
2625
"os"
27-
"time"
2826

2927
libMetrics "github.com/IBM/ibmcloud-volume-interface/lib/metrics"
3028
k8sUtils "github.com/IBM/secret-utils-lib/pkg/k8s_utils"
@@ -58,7 +56,6 @@ var (
5856

5957
func main() {
6058
flag.Parse()
61-
rand.Seed(time.Now().UnixNano())
6259
handle(logger)
6360
os.Exit(0)
6461
}

deploy/kubernetes/driver/kubernetes/manifests/config-map.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ data:
7474
BlockDriverMemoryLimit: "600Mi" #container:iks-vpc-block-driver, resource-type: memory-limit
7575
CSISnapshotterCPULimit: "80m" #container:csi-snapshotter, resource-type: cpu-limit
7676
CSISnapshotterMemoryLimit: "160Mi" #container:csi-snapshotter, resource-type: memory-limit
77+
VolumeAttachmentLimit: "12" #Volume Attachment Limit per node

deploy/kubernetes/driver/kubernetes/manifests/controller-server.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
kind: StatefulSet
1+
kind: Deployment
22
apiVersion: apps/v1
33
metadata:
44
name: ibm-vpc-block-csi-controller
55
namespace: kube-system
66
labels:
7-
app: ibm-vpc-block-csi-driver
7+
app: ibm-vpc-block-csi-controller
88
addonmanager.kubernetes.io/mode: Reconcile
9+
app.kubernetes.io/name: ibm-vpc-block-csi-driver
910
spec:
10-
serviceName: "ibm-vpc-block-service"
1111
replicas: 1
1212
selector:
1313
matchLabels:
14-
app: ibm-vpc-block-csi-driver
14+
app: ibm-vpc-block-csi-controller
15+
app.kubernetes.io/name: ibm-vpc-block-csi-driver
1516
template:
1617
metadata:
1718
annotations:
1819
prometheus.io/scrape: "true"
1920
prometheus.io/port: "9080"
2021
prometheus.io/path: "/metrics"
2122
labels:
22-
app: ibm-vpc-block-csi-driver
23+
app: ibm-vpc-block-csi-controller
24+
app.kubernetes.io/name: ibm-vpc-block-csi-driver
2325
spec:
2426
priorityClassName: system-cluster-critical
2527
serviceAccountName: ibm-vpc-block-controller-sa
@@ -207,4 +209,3 @@ spec:
207209
- name: customer-auth
208210
secret:
209211
secretName: storage-secret-store
210-
volumeClaimTemplates: []

deploy/kubernetes/driver/kubernetes/manifests/node-server.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@ metadata:
44
name: ibm-vpc-block-csi-node
55
namespace: kube-system
66
labels:
7-
app: ibm-vpc-block-csi-driver
7+
app: ibm-vpc-block-csi-node
88
addonmanager.kubernetes.io/mode: Reconcile
9+
app.kubernetes.io/name: ibm-vpc-block-csi-driver
910
spec:
1011
selector:
1112
matchLabels:
12-
app: ibm-vpc-block-csi-driver
13+
app: ibm-vpc-block-csi-node
14+
app.kubernetes.io/name: ibm-vpc-block-csi-driver
1315
template:
1416
metadata:
1517
annotations:
1618
prometheus.io/scrape: "true"
1719
prometheus.io/port: "9080"
1820
prometheus.io/path: "/metrics"
1921
labels:
20-
app: ibm-vpc-block-csi-driver
22+
app: ibm-vpc-block-csi-node
23+
app.kubernetes.io/name: ibm-vpc-block-csi-driver
2124
spec:
2225
priorityClassName: system-node-critical
2326
serviceAccountName: ibm-vpc-block-node-sa
@@ -44,6 +47,8 @@ spec:
4447
valueFrom:
4548
fieldRef:
4649
fieldPath: spec.nodeName
50+
- name: VOLUME_ATTACHMENT_LIMIT
51+
value: "{{kube-system.addon-vpc-block-csi-driver-configmap.VolumeAttachmentLimit}}{{^kube-system.addon-vpc-block-csi-driver-configmap.VolumeAttachmentLimit}}12{{/kube-system.addon-vpc-block-csi-driver-configmap.VolumeAttachmentLimit}}"
4752
resources:
4853
limits:
4954
cpu: "{{kube-system.addon-vpc-block-csi-driver-configmap.CSIDriverRegistrarCPULimit}}{{^kube-system.addon-vpc-block-csi-driver-configmap.CSIDriverRegistrarCPULimit}}40m{{/kube-system.addon-vpc-block-csi-driver-configmap.CSIDriverRegistrarCPULimit}}"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: snapshot.storage.k8s.io/v1
2+
kind: VolumeSnapshot
3+
metadata:
4+
name: snapshot-csi-block
5+
spec:
6+
volumeSnapshotClassName: ibmc-vpcblock-snapshot
7+
source:
8+
persistentVolumeClaimName: csi-block-pvc-good
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: restore-pvc1
5+
spec:
6+
storageClassName: ibmc-vpc-block-5iops-tier
7+
dataSource:
8+
name: snapshot-csi-block # name of volumeSnapshot resource
9+
kind: VolumeSnapshot
10+
apiGroup: snapshot.storage.k8s.io
11+
accessModes:
12+
- ReadWriteOnce
13+
resources:
14+
requests:
15+
storage: 10Gi # size must be >= source PVC
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: snapshot.storage.k8s.io/v1
2+
kind: VolumeSnapshotClass
3+
metadata:
4+
name: ibmc-vpcblock-snapshot-delete
5+
labels:
6+
app: ibm-vpc-block-csi-driver
7+
driver: vpc.block.csi.ibm.io
8+
deletionPolicy: Delete

examples/kubernetes/static-pod.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: static-pvc-pod
5+
labels:
6+
app: static-pvc-pod
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: static-pvc-pod
11+
template:
12+
metadata:
13+
labels:
14+
app: static-pvc-pod
15+
spec:
16+
containers:
17+
- image: rabbitmq
18+
name: rabbitmq-container
19+
volumeMounts:
20+
- name: my-static-vol
21+
mountPath: /my-static-vol
22+
volumes:
23+
- name: my-static-vol
24+
persistentVolumeClaim:
25+
claimName: static-pvc # Update your pvc name here
26+
nodeSelector:
27+
kubernetes.io/hostname: "10.240.0.7" # Update hostname as node name which should match as per volume's zone

examples/kubernetes/static-pv.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: PersistentVolume
3+
metadata:
4+
name: static-pv
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce # Should be matched as per PVC's requested accessMode
8+
capacity:
9+
storage: 10Gi # Should be matched as per PVC's request storage
10+
csi:
11+
driver: vpc.block.csi.ibm.io
12+
fsType: ext4
13+
volumeAttributes:
14+
iops: "3000"
15+
volumeId: r006-ab62267d-ad2f-43ec-a22e-23007a9d2618
16+
zone: us-south-1
17+
region: us-south
18+
volumeHandle: r006-ab62267d-ad2f-43ec-a22e-23007a9d2618
19+
persistentVolumeReclaimPolicy: Retain
20+
storageClassName: ""
21+
volumeMode: Filesystem

examples/kubernetes/static-pvc.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: static-pvc
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 10 # Update vpc data volume size which should match as per pv's size
11+
storageClassName: ""

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module github.com/kubernetes-sigs/ibm-vpc-block-csi-driver
22

3-
go 1.18
3+
go 1.20
44

55
require (
66
github.com/IBM/ibm-csi-common v1.1.7
77
github.com/IBM/ibmcloud-volume-interface v1.2.0
8-
github.com/IBM/ibmcloud-volume-vpc v1.1.5
8+
github.com/IBM/ibmcloud-volume-vpc v1.1.6
99
github.com/IBM/secret-utils-lib v1.1.4
1010
github.com/container-storage-interface/spec v1.7.0
1111
github.com/golang/glog v1.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ github.com/IBM/ibm-csi-common v1.1.7 h1:4QY86ZJ8rX1ghrhytgIY+VoEemeG+J2PbvzXTuYZ
4343
github.com/IBM/ibm-csi-common v1.1.7/go.mod h1:TilE1H+F4rzhgnEHHDzdcJ9M+WcJB6QCBxwtGdCDv7A=
4444
github.com/IBM/ibmcloud-volume-interface v1.2.0 h1:9SqCaC0H6nhiXZL57FsR0n1B7rQ7CVW86kjVKqGmMck=
4545
github.com/IBM/ibmcloud-volume-interface v1.2.0/go.mod h1:646HOeq8dAKbgpr7jRehGKckhgduJyII2uN5T6RDLww=
46-
github.com/IBM/ibmcloud-volume-vpc v1.1.5 h1:dN/LxVxtkiK0g4JzDP2VnHoh+LfHwPyzB+TgUZbhVyU=
47-
github.com/IBM/ibmcloud-volume-vpc v1.1.5/go.mod h1:+UTHGrGzjyA2VjaozhB1xOjAcJ1lsi9mFqfGsqmuCOQ=
46+
github.com/IBM/ibmcloud-volume-vpc v1.1.6 h1:HU76slo59S6vPANtQxTDdco+Lu7EToQw7Ow28n5eZR0=
47+
github.com/IBM/ibmcloud-volume-vpc v1.1.6/go.mod h1:+UTHGrGzjyA2VjaozhB1xOjAcJ1lsi9mFqfGsqmuCOQ=
4848
github.com/IBM/secret-common-lib v1.1.4 h1:gKpKnaP45Y6u7VpSlFfXjjTAHpu4bz9Ofy+aR0t2RcI=
4949
github.com/IBM/secret-common-lib v1.1.4/go.mod h1:0L/lLfwi5jwTTmNYE2246HzBIdGz0m6wu/5tXoRp/Lc=
5050
github.com/IBM/secret-utils-lib v1.1.4 h1:8WPG9KBrLLRhGbQn34NWzrFKlyfIIaUfLeDg+iRJkes=

hack/verify-golint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ set -euo pipefail
1818
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin latest
1919
if [[ -z "$(command -v golangci-lint)" ]]; then
2020
echo "Cannot find golangci-lint. Installing golangci-lint..."
21-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
21+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2
2222
export PATH=$PATH:$(go env GOPATH)/bin
2323
fi
2424

2525
echo "Verifying golint"
2626
readonly PKG_ROOT="$(git rev-parse --show-toplevel)"
2727

28-
golangci-lint run --deadline=10m
28+
golangci-lint run --timeout=10m
2929

3030
echo "Congratulations! Lint check completed for all Go source files."

pkg/ibmcsidriver/constants.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ const (
115115

116116
// Generation ... just for backward compatibility
117117
Generation = "generation"
118+
119+
// DEFAULT_SNAPSHOT_CREATE_DELAY ...
120+
DEFAULT_SNAPSHOT_CREATE_DELAY = 300 //300 seconds
121+
122+
// MAX_SNAPSHOT_CREATE_DELAY ... This is max timeout value for csi-snapshotter
123+
MAX_SNAPSHOT_CREATE_DELAY = 900 //900 seconds
118124
)
119125

120126
// SupportedFS the supported FS types

pkg/ibmcsidriver/controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818
package ibmcsidriver
1919

2020
import (
21+
"os"
2122
"strings"
2223
"time"
2324

@@ -215,7 +216,7 @@ func (csiCS *CSIControllerServer) ControllerPublishVolume(ctx context.Context, r
215216
lockWaitStart := time.Now()
216217
csiCS.mutex.Lock(nodeID)
217218
defer csiCS.mutex.Unlock(nodeID)
218-
metrics.UpdateDurationFromStart(ctxLogger, metrics.FunctionLabel("ControllerPublishVolume.Lock"), lockWaitStart)
219+
defer metrics.UpdateDurationFromStart(ctxLogger, metrics.FunctionLabel("ControllerPublishVolume.Lock"), lockWaitStart)
219220

220221
volumeCapabilities := []*csi.VolumeCapability{volumeCapability}
221222
// Validate volume capabilities, are all capabilities supported by driver or not
@@ -439,6 +440,13 @@ func (csiCS *CSIControllerServer) CreateSnapshot(ctx context.Context, req *csi.C
439440
ctxLogger.Info("CSIControllerServer-CreateSnapshot... ", zap.Reflect("Request", *req))
440441
defer metrics.UpdateDurationFromStart(ctxLogger, "CreateSnapshot", time.Now())
441442

443+
//Feature flag to enable/disable CreateSnapshot feature.
444+
if strings.ToLower(os.Getenv("IS_SNAPSHOT_ENABLED")) == "false" {
445+
ctxLogger.Warn("CreateSnapshot functionality is disabled.")
446+
time.Sleep(10 * time.Minute) //To avoid multiple retries from kubernetes to CSI Driver
447+
return nil, commonError.GetCSIError(ctxLogger, commonError.MethodUnimplemented, requestID, nil, "CreateSnapshot functionality is disabled.")
448+
}
449+
442450
snapshotName := req.GetName()
443451
if len(snapshotName) == 0 {
444452
return nil, commonError.GetCSIError(ctxLogger, commonError.MissingSnapshotName, requestID, nil)
@@ -479,6 +487,7 @@ func (csiCS *CSIControllerServer) CreateSnapshot(ctx context.Context, req *csi.C
479487
snapshot, err = session.CreateSnapshot(sourceVolumeID, snapshotParameters)
480488

481489
if err != nil {
490+
time.Sleep(time.Duration(getMaxDelaySnapshotCreate(ctxLogger)) * time.Second) //To avoid multiple retries from kubernetes to CSI Driver
482491
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err, "creation")
483492
}
484493
return createCSISnapshotResponse(*snapshot), nil

pkg/ibmcsidriver/controller_helper.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package ibmcsidriver
1919

2020
import (
2121
"fmt"
22+
"os"
2223
"strconv"
2324
"strings"
2425

@@ -508,3 +509,27 @@ func getPrefedTopologyParams(topList []*csi.Topology) (map[string]string, error)
508509
}
509510
return nil, fmt.Errorf("preferred topologies specified but no segments")
510511
}
512+
513+
/*
514+
1.) IF user does not given the value DEFAULT_SNAPSHOT_CREATE_DELAY mins
515+
2.) IF user has given more than MAX_SNAPSHOT_CREATE_DELAY default is MAX_SNAPSHOT_CREATE_DELAY
516+
3.) In case of any invalid value DEFAULT_SNAPSHOT_CREATE_DELAY mins
517+
*/
518+
func getMaxDelaySnapshotCreate(ctxLogger *zap.Logger) int {
519+
userDelayEnv := os.Getenv("CUSTOM_SNAPSHOT_CREATE_DELAY")
520+
if userDelayEnv == "" {
521+
return DEFAULT_SNAPSHOT_CREATE_DELAY
522+
}
523+
524+
customSnapshotCreateDelay, err := strconv.Atoi(userDelayEnv)
525+
if err != nil {
526+
ctxLogger.Warn("Error while processing CUSTOM_SNAPSHOT_CREATE_DELAY value.Expecting integer value in seconds", zap.Any("CUSTOM_SNAPSHOT_CREATE_DELAY", customSnapshotCreateDelay), zap.Any("Considered value", DEFAULT_SNAPSHOT_CREATE_DELAY), zap.Error(err))
527+
return DEFAULT_SNAPSHOT_CREATE_DELAY // min 300 seconds default
528+
}
529+
if customSnapshotCreateDelay > MAX_SNAPSHOT_CREATE_DELAY {
530+
ctxLogger.Warn("CUSTOM_SNAPSHOT_CREATE_DELAY value cannot exceed the limits", zap.Any("CUSTOM_SNAPSHOT_CREATE_DELAY", customSnapshotCreateDelay), zap.Any("Limit value", MAX_SNAPSHOT_CREATE_DELAY))
531+
return MAX_SNAPSHOT_CREATE_DELAY // max 900 seconds
532+
}
533+
534+
return customSnapshotCreateDelay
535+
}

pkg/ibmcsidriver/ibm_csi_driver.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ type IBMCSIDriver struct {
3535
vendorVersion string
3636
logger *zap.Logger
3737
region string
38-
39-
ids *CSIIdentityServer
40-
ns *CSINodeServer
41-
cs *CSIControllerServer
38+
ids *CSIIdentityServer
39+
ns *CSINodeServer
40+
cs *CSIControllerServer
4241

4342
vcap []*csi.VolumeCapability_AccessMode
4443
cscap []*csi.ControllerServiceCapability

0 commit comments

Comments
 (0)