Skip to content

Commit c9e0e21

Browse files
Merge pull request kubernetes-csi#53 from shiftstack/merge-bot-master
Merge https://github.com/kubernetes-csi/csi-driver-nfs:master into master
2 parents 377eb9d + 44fe641 commit c9e0e21

File tree

9 files changed

+483
-257
lines changed

9 files changed

+483
-257
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ARG ARCH=amd64
1717
FROM k8s.gcr.io/build-image/debian-base:buster-v1.6.0
1818

1919
# Copy nfsplugin from build _output directory
20-
COPY bin/nfsplugin /nfsplugin
20+
COPY bin/${ARCH}/nfsplugin /nfsplugin
2121

2222
# this is a workaround to install nfs-common & nfs-kernel-server and don't quit with error
2323
# https://github.com/kubernetes-sigs/blob-csi-driver/issues/214#issuecomment-781602430

Makefile

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ IMAGE_TAG_LATEST = $(REGISTRY)/$(IMAGENAME):latest
4545
E2E_HELM_OPTIONS ?= --set image.nfs.repository=$(REGISTRY)/$(IMAGENAME) --set image.nfs.tag=$(IMAGE_VERSION) --set image.nfs.pullPolicy=Always
4646
E2E_HELM_OPTIONS += ${EXTRA_HELM_OPTIONS}
4747

48+
# Output type of docker buildx build
49+
OUTPUT_TYPE ?= docker
50+
51+
ALL_ARCH.linux = arm64 amd64
52+
ALL_OS_ARCH = linux-arm64 linux-arm-v7 linux-amd64
53+
54+
.EXPORT_ALL_VARIABLES:
55+
4856
all: nfs
4957

5058
.PHONY: verify
@@ -88,20 +96,57 @@ local-k8s-uninstall:
8896

8997
.PHONY: nfs
9098
nfs:
91-
CGO_ENABLED=0 GOOS=linux go build -a -ldflags "${LDFLAGS} ${EXT_LDFLAGS}" -mod vendor -o bin/nfsplugin ./cmd/nfsplugin
99+
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags "${LDFLAGS} ${EXT_LDFLAGS}" -mod vendor -o bin/${ARCH}/nfsplugin ./cmd/nfsplugin
100+
101+
.PHONY: nfs-armv7
102+
nfs-armv7:
103+
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -ldflags "${LDFLAGS} ${EXT_LDFLAGS}" -mod vendor -o bin/arm/v7/nfsplugin ./cmd/nfsplugin
104+
105+
.PHONY: container-build
106+
container-build:
107+
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="linux/$(ARCH)" \
108+
-t $(IMAGE_TAG)-linux-$(ARCH) --build-arg ARCH=$(ARCH) .
109+
110+
.PHONY: container-linux-armv7
111+
container-linux-armv7:
112+
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="linux/arm/v7" \
113+
-t $(IMAGE_TAG)-linux-arm-v7 --build-arg ARCH=arm/v7 .
92114

93115
.PHONY: container
94-
container: nfs
95-
docker build --no-cache -t $(IMAGE_TAG) .
116+
container:
117+
docker buildx rm container-builder || true
118+
docker buildx create --use --name=container-builder
119+
# enable qemu for arm64 build
120+
# https://github.com/docker/buildx/issues/464#issuecomment-741507760
121+
docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-aarch64
122+
docker run --rm --privileged tonistiigi/binfmt --install all
123+
for arch in $(ALL_ARCH.linux); do \
124+
ARCH=$${arch} $(MAKE) nfs; \
125+
ARCH=$${arch} $(MAKE) container-build; \
126+
done
127+
$(MAKE) nfs-armv7
128+
$(MAKE) container-linux-armv7
96129

97130
.PHONY: push
98131
push:
132+
ifdef CI
133+
docker manifest create --amend $(IMAGE_TAG) $(foreach osarch, $(ALL_OS_ARCH), $(IMAGE_TAG)-${osarch})
134+
docker manifest push --purge $(IMAGE_TAG)
135+
docker manifest inspect $(IMAGE_TAG)
136+
else
99137
docker push $(IMAGE_TAG)
138+
endif
100139

101140
.PHONY: push-latest
102141
push-latest:
142+
ifdef CI
143+
docker manifest create --amend $(IMAGE_TAG_LATEST) $(foreach osarch, $(ALL_OS_ARCH), $(IMAGE_TAG)-${osarch})
144+
docker manifest push --purge $(IMAGE_TAG_LATEST)
145+
docker manifest inspect $(IMAGE_TAG_LATEST)
146+
else
103147
docker tag $(IMAGE_TAG) $(IMAGE_TAG_LATEST)
104148
docker push $(IMAGE_TAG_LATEST)
149+
endif
105150

106151
.PHONY: install-nfs-server
107152
install-nfs-server:
@@ -113,7 +158,7 @@ install-helm:
113158

114159
.PHONY: e2e-bootstrap
115160
e2e-bootstrap: install-helm
116-
docker pull $(IMAGE_TAG) || make container push
161+
OUTPUT_TYPE=registry $(MAKE) container push
117162
helm install csi-driver-nfs ./charts/latest/csi-driver-nfs --namespace kube-system --wait --timeout=15m -v=5 --debug \
118163
${E2E_HELM_OPTIONS} \
119164
--set controller.logLevel=8 \

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/kubernetes-csi/csi-driver-nfs
33
go 1.16
44

55
require (
6-
github.com/container-storage-interface/spec v1.3.0
6+
github.com/container-storage-interface/spec v1.5.0
77
github.com/golang/protobuf v1.4.3
88
github.com/kubernetes-csi/csi-lib-utils v0.9.0
99
github.com/kubernetes-csi/external-snapshotter/v2 v2.0.0-20200617021606-4800ca72d403

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z
127127
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
128128
github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
129129
github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
130-
github.com/container-storage-interface/spec v1.3.0 h1:wMH4UIoWnK/TXYw8mbcIHgZmB6kHOeIsYsiaTJwa6bc=
131130
github.com/container-storage-interface/spec v1.3.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
131+
github.com/container-storage-interface/spec v1.5.0 h1:lvKxe3uLgqQeVQcrnL2CPQKISoKjTJxojEs9cBk+HXo=
132+
github.com/container-storage-interface/spec v1.5.0/go.mod h1:8K96oQNkJ7pFcC2R9Z1ynGGBB1I93kcS6PGg3SsOk8s=
132133
github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM=
133134
github.com/containerd/console v0.0.0-20170925154832-84eeaae905fa/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
134135
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=

pkg/nfs/controllerserver_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ func TestControllerGetCapabilities(t *testing.T) {
331331
},
332332
},
333333
},
334+
{
335+
Type: &csi.ControllerServiceCapability_Rpc{
336+
Rpc: &csi.ControllerServiceCapability_RPC{
337+
Type: csi.ControllerServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
338+
},
339+
},
340+
},
334341
},
335342
},
336343
expectedErr: nil,

pkg/nfs/nfs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ func NewNFSdriver(nodeID, driverName, endpoint string, perm *uint32) *Driver {
7171
vcam := []csi.VolumeCapability_AccessMode_Mode{
7272
csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
7373
csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY,
74+
csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER,
75+
csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER,
7476
csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY,
7577
csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER,
7678
csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
@@ -82,10 +84,12 @@ func NewNFSdriver(nodeID, driverName, endpoint string, perm *uint32) *Driver {
8284
// ControllerServiceCapability RPC types.
8385
n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
8486
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
87+
csi.ControllerServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
8588
})
8689

8790
n.AddNodeServiceCapabilities([]csi.NodeServiceCapability_RPC_Type{
8891
csi.NodeServiceCapability_RPC_GET_VOLUME_STATS,
92+
csi.NodeServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
8993
csi.NodeServiceCapability_RPC_UNKNOWN,
9094
})
9195
n.volumeLocks = NewVolumeLocks()

test/sanity/run-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function install_csi_sanity_bin {
3131
mkdir -p $GOPATH/src/github.com/kubernetes-csi
3232
pushd $GOPATH/src/github.com/kubernetes-csi
3333
export GO111MODULE=off
34-
git clone https://github.com/kubernetes-csi/csi-test.git -b v4.0.2
34+
git clone https://github.com/kubernetes-csi/csi-test.git -b v4.2.0
3535
pushd csi-test/cmd/csi-sanity
3636
make install
3737
popd
@@ -60,4 +60,4 @@ bin/nfsplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 &
6060

6161
echo 'Begin to run sanity test...'
6262
readonly CSI_SANITY_BIN='csi-sanity'
63-
"$CSI_SANITY_BIN" --ginkgo.v --csi.testvolumeparameters="$(pwd)/test/sanity/params.yaml" --csi.endpoint="$endpoint" --ginkgo.skip="should not fail when requesting to create a volume with already existing name and same capacity|should fail when requesting to create a volume with already existing name and different capacity|should work|should fail when the requested volume does not exist"
63+
"$CSI_SANITY_BIN" --ginkgo.v --csi.testvolumeparameters="$(pwd)/test/sanity/params.yaml" --csi.endpoint="$endpoint" --ginkgo.skip="should not fail when requesting to create a volume with already existing name and same capacity|should fail when requesting to create a volume with already existing name and different capacity|should work|should fail when the requested volume does not exist|should return appropriate capabilities"

0 commit comments

Comments
 (0)