Skip to content

Commit 8a84d45

Browse files
committed
update csi spec and protoc
1 parent 10eec6d commit 8a84d45

File tree

14 files changed

+14107
-13318
lines changed

14 files changed

+14107
-13318
lines changed

connection/connection_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,6 @@ const (
5353
serverSock = "server.sock"
5454
)
5555

56-
type identityServer struct{}
57-
58-
func (ids *identityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
59-
return nil, status.Error(codes.Unimplemented, "Unimplemented")
60-
}
61-
62-
func (ids *identityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
63-
return nil, status.Error(codes.Unimplemented, "Unimplemented")
64-
}
65-
66-
func (ids *identityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
67-
return nil, status.Error(codes.Unimplemented, "Unimplemented")
68-
}
69-
7056
// startServer creates a gRPC server without any registered services.
7157
// The returned address can be used to connect to it. The cleanup
7258
// function stops it. It can be called multiple times.
@@ -458,7 +444,7 @@ func TestConnectMetrics(t *testing.T) {
458444
cmmServer := metrics.NewCSIMetricsManagerForPlugin("fake.csi.driver.io")
459445
// We have to have a real implementation of the gRPC call, otherwise the metrics
460446
// interceptor is not called. The CSI identity service is used because it's simple.
461-
addr, stopServer := startServer(t, tmp, &identityServer{}, nil, cmmServer)
447+
addr, stopServer := startServer(t, tmp, &csi.UnimplementedIdentityServer{}, nil, cmmServer)
462448
defer stopServer()
463449

464450
cmm := test.cmm
@@ -516,7 +502,7 @@ func TestConnectWithOtelGrpcInterceptorTraces(t *testing.T) {
516502
defer os.RemoveAll(tmp)
517503
// We have to have a real implementation of the gRPC call, otherwise the trace
518504
// interceptor is not called. The CSI identity service is used because it's simple.
519-
addr, stopServer := startServer(t, tmp, &identityServer{}, nil, nil)
505+
addr, stopServer := startServer(t, tmp, &csi.UnimplementedIdentityServer{}, nil, nil)
520506
defer stopServer()
521507

522508
_, ctx := ktesting.NewTestContext(t)

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-lib-utils
33
go 1.22.5
44

55
require (
6-
github.com/container-storage-interface/spec v1.9.0
6+
github.com/container-storage-interface/spec v1.10.0
77
github.com/golang/protobuf v1.5.4
88
github.com/stretchr/testify v1.9.0
99
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
99
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
1010
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnThWgvH2wg8376yUJmPhEH4H3kw=
1111
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
12-
github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY=
13-
github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0=
12+
github.com/container-storage-interface/spec v1.10.0 h1:YkzWPV39x+ZMTa6Ax2czJLLwpryrQ+dPesB34mrRMXA=
13+
github.com/container-storage-interface/spec v1.10.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
1414
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
1515
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1616
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

protosanitizer/protosanitizer_test.go

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import (
2020
"fmt"
2121
"testing"
2222

23+
"github.com/container-storage-interface/spec/lib/go/csi"
2324
"github.com/golang/protobuf/proto"
24-
csi03 "github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test/csi03"
25-
csi "github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test/csi10"
2625
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test/csitest"
2726
"github.com/stretchr/testify/assert"
2827
)
@@ -31,42 +30,6 @@ func TestStripSecrets(t *testing.T) {
3130
secretName := "secret-abc"
3231
secretValue := "123"
3332

34-
// CSI 0.3.0.
35-
createVolumeCSI03 := &csi03.CreateVolumeRequest{
36-
AccessibilityRequirements: &csi03.TopologyRequirement{
37-
Requisite: []*csi03.Topology{
38-
&csi03.Topology{
39-
Segments: map[string]string{
40-
"foo": "bar",
41-
"x": "y",
42-
},
43-
},
44-
&csi03.Topology{
45-
Segments: map[string]string{
46-
"a": "b",
47-
},
48-
},
49-
},
50-
},
51-
Name: "foo",
52-
VolumeCapabilities: []*csi03.VolumeCapability{
53-
&csi03.VolumeCapability{
54-
AccessType: &csi03.VolumeCapability_Mount{
55-
Mount: &csi03.VolumeCapability_MountVolume{
56-
FsType: "ext4",
57-
},
58-
},
59-
},
60-
},
61-
CapacityRange: &csi03.CapacityRange{
62-
RequiredBytes: 1024,
63-
},
64-
ControllerCreateSecrets: map[string]string{
65-
secretName: secretValue,
66-
"secret-xyz": "987",
67-
},
68-
}
69-
7033
// Current spec.
7134
createVolume := &csi.CreateVolumeRequest{
7235
AccessibilityRequirements: &csi.TopologyRequirement{
@@ -179,7 +142,6 @@ func TestStripSecrets(t *testing.T) {
179142
AccessibilityRequirements: &csi.TopologyRequirement{},
180143
}, `{"accessibility_requirements":{},"capacity_range":{"limit_bytes":1024,"required_bytes":1024},"name":"test-volume","parameters":{"param1":"param1","param2":"param2"},"secrets":"***stripped***","volume_capabilities":[{"AccessType":{"Mount":{"fs_type":"ext4","mount_flags":["flag1","flag2","flag3"]}},"access_mode":{"mode":5}}],"volume_content_source":{"Type":null}}`},
181144
{createVolume, `{"accessibility_requirements":{"requisite":[{"segments":{"foo":"bar","x":"y"}},{"segments":{"a":"b"}}]},"capacity_range":{"required_bytes":1024},"name":"foo","secrets":"***stripped***","volume_capabilities":[{"AccessType":{"Mount":{"fs_type":"ext4"}}}]}`},
182-
{createVolumeCSI03, `{"accessibility_requirements":{"requisite":[{"segments":{"foo":"bar","x":"y"}},{"segments":{"a":"b"}}]},"capacity_range":{"required_bytes":1024},"controller_create_secrets":"***stripped***","name":"foo","volume_capabilities":[{"AccessType":{"Mount":{"fs_type":"ext4"}}}]}`},
183145
{&csitest.CreateVolumeRequest{}, `{}`},
184146
{createVolumeFuture,
185147
// Secrets are *not* removed from all fields yet. This will have to be fixed one way or another
@@ -203,12 +165,7 @@ func TestStripSecrets(t *testing.T) {
203165

204166
for _, c := range cases {
205167
before := fmt.Sprint(c.original)
206-
var stripped fmt.Stringer
207-
if _, ok := c.original.(*csi03.CreateVolumeRequest); ok {
208-
stripped = StripSecretsCSI03(c.original)
209-
} else {
210-
stripped = StripSecrets(c.original)
211-
}
168+
stripped := StripSecrets(c.original)
212169
if assert.Equal(t, c.stripped, stripped.String(), "unexpected result for fmt s of %s", c.original) {
213170
if assert.Equal(t, c.stripped, fmt.Sprintf("%v", stripped), "unexpected result for fmt v of %s", c.original) {
214171
assert.Equal(t, c.stripped, fmt.Sprintf("%+v", stripped), "unexpected result for fmt +v of %s", c.original)

protosanitizer/test/Makefile

Lines changed: 19 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export GOPATH
2121

2222
# Only set PROTOC_VER if it has an empty value.
2323
ifeq (,$(strip $(PROTOC_VER)))
24-
PROTOC_VER := 3.5.1
24+
PROTOC_VER := 25.2
2525
endif
2626

2727
PROTOC_OS := $(shell uname -s)
@@ -32,42 +32,26 @@ endif
3232
PROTOC_ARCH := $(shell uname -m)
3333
ifeq (i386,$(PROTOC_ARCH))
3434
PROTOC_ARCH := x86_32
35+
else ifeq (arm64,$(PROTOC_ARCH))
36+
PROTOC_ARCH := aarch_64
3537
endif
3638

37-
PROTOC := ./protoc
3839
PROTOC_ZIP := protoc-$(PROTOC_VER)-$(PROTOC_OS)-$(PROTOC_ARCH).zip
3940
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VER)/$(PROTOC_ZIP)
4041
PROTOC_TMP_DIR := .protoc
41-
PROTOC_TMP_BIN := $(PROTOC_TMP_DIR)/bin/protoc
42+
PROTOC := $(PROTOC_TMP_DIR)/bin/protoc
43+
44+
$(GOBIN)/protoc-gen-go: ../../go.mod
45+
go install -mod=readonly google.golang.org/protobuf/cmd/protoc-gen-go
4246

4347
$(PROTOC):
4448
-mkdir -p "$(PROTOC_TMP_DIR)" && \
4549
curl -L $(PROTOC_URL) -o "$(PROTOC_TMP_DIR)/$(PROTOC_ZIP)" && \
4650
unzip "$(PROTOC_TMP_DIR)/$(PROTOC_ZIP)" -d "$(PROTOC_TMP_DIR)" && \
47-
chmod 0755 "$(PROTOC_TMP_BIN)" && \
48-
cp -f "$(PROTOC_TMP_BIN)" "$@"
51+
chmod 0755 "$@"
4952
stat "$@" > /dev/null 2>&1
5053

51-
52-
########################################################################
53-
## PROTOC-GEN-GO ##
54-
########################################################################
55-
56-
# This is the recipe for getting and installing the go plug-in
57-
# for protoc
58-
PROTOC_GEN_GO_PKG := github.com/golang/protobuf/protoc-gen-go
59-
PROTOC_GEN_GO := protoc-gen-go
60-
$(PROTOC_GEN_GO): PROTOBUF_PKG := $(dir $(PROTOC_GEN_GO_PKG))
61-
$(PROTOC_GEN_GO): PROTOBUF_VERSION := v1.2.0
62-
$(PROTOC_GEN_GO):
63-
mkdir -p $(dir $(GOPATH)/src/$(PROTOBUF_PKG))
64-
test -d $(GOPATH)/src/$(PROTOBUF_PKG)/.git || git clone https://$(PROTOBUF_PKG) $(GOPATH)/src/$(PROTOBUF_PKG)
65-
(cd $(GOPATH)/src/$(PROTOBUF_PKG) && \
66-
(test "$$(git describe --tags | head -1)" = "$(PROTOBUF_VERSION)" || \
67-
(git fetch && git checkout tags/$(PROTOBUF_VERSION))))
68-
(cd $(GOPATH)/src/$(PROTOBUF_PKG) && go get -v -d $$(go list -f '{{ .ImportPath }}' ./...)) && \
69-
go build -o "$@" $(PROTOC_GEN_GO_PKG)
70-
54+
PROTOC_ALL := $(GOBIN)/protoc-gen-go $(PROTOC)
7155

7256
########################################################################
7357
## PATH ##
@@ -78,59 +62,27 @@ $(PROTOC_GEN_GO):
7862
# directory.
7963
export PATH := $(shell pwd):$(PATH)
8064

81-
8265
########################################################################
8366
## BUILD ##
8467
########################################################################
8568
CSI_PROTO := ./csitest.proto
86-
CSI_PKG_ROOT := github.com/kubernetes-csi/csi-lib-utils/protosanitizer/test
87-
CSI_PKG_SUB := $(shell cat $(CSI_PROTO) | sed -n -e 's/^package.\([^;]*\).v[0-9]\+;$$/\1/p'|tr '.' '/')
88-
CSI_BUILD := $(CSI_PKG_SUB)/.build
69+
CSI_PKG_SUB := csitest
8970
CSI_GO := $(CSI_PKG_SUB)/csitest.pb.go
90-
CSI_A := csi.a
91-
CSI_GO_TMP := $(CSI_BUILD)/$(CSI_PKG_ROOT)/csitest.pb.go
92-
93-
# This recipe generates the go language bindings to a temp area.
94-
$(CSI_GO_TMP): HERE := $(shell pwd)
95-
$(CSI_GO_TMP): PTYPES_PKG := github.com/golang/protobuf/ptypes
96-
$(CSI_GO_TMP): GO_OUT := plugins=grpc
97-
$(CSI_GO_TMP): GO_OUT := $(GO_OUT),Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor
98-
$(CSI_GO_TMP): GO_OUT := $(GO_OUT),Mgoogle/protobuf/wrappers.proto=$(PTYPES_PKG)/wrappers
99-
$(CSI_GO_TMP): GO_OUT := $(GO_OUT):"$(HERE)/$(CSI_BUILD)"
100-
$(CSI_GO_TMP): INCLUDE := -I$(GOPATH)/src -I$(HERE)/$(PROTOC_TMP_DIR)/include
101-
$(CSI_GO_TMP): $(CSI_PROTO) | $(PROTOC) $(PROTOC_GEN_GO)
102-
@mkdir -p "$(@D)"
103-
(cd "$(GOPATH)/src" && \
104-
$(HERE)/$(PROTOC) $(INCLUDE) --go_out=$(GO_OUT) "$(CSI_PKG_ROOT)/$(<F)")
105-
106-
# The temp language bindings are compared to the ones that are
107-
# versioned. If they are different then it means the language
108-
# bindings were not updated prior to being committed.
109-
$(CSI_GO): $(CSI_GO_TMP)
110-
ifeq (true,$(TRAVIS))
111-
diff "$@" "$?"
112-
else
113-
@mkdir -p "$(@D)"
114-
diff "$@" "$?" > /dev/null 2>&1 || cp -f "$?" "$@"
115-
endif
11671

117-
# This recipe builds the Go archive from the sources in three steps:
118-
#
119-
# 1. Go get any missing dependencies.
120-
# 2. Cache the packages.
121-
# 3. Build the archive file.
122-
$(CSI_A): $(CSI_GO)
123-
go get -v -d ./...
124-
go install ./$(CSI_PKG_SUB)
125-
go build -o "$@" ./$(CSI_PKG_SUB)
72+
# This recipe generates the go language bindings
73+
$(CSI_GO): $(CSI_PROTO) $(PROTOC_ALL)
74+
@mkdir -p "$(@D)"
75+
$(PROTOC) --go_out=$(CSI_PKG_SUB) \
76+
--go_opt=paths=source_relative \
77+
"$(<F)"
12678

127-
build: $(CSI_A)
79+
build: $(CSI_GO) $(CSI_GRPC)
12880

12981
clean:
13082
go clean -i ./...
131-
rm -rf "$(CSI_A)" "$(CSI_GO)" "$(CSI_BUILD)"
83+
rm -rf "$(CSI_PKG_SUB)"
13284

13385
clobber: clean
134-
rm -fr "$(PROTOC)" "$(PROTOC_GEN_GO)" "$(CSI_PKG_SUB)" "$(PROTOC_TMP_DIR)"
86+
rm -fr "$(PROTOC_TMP_DIR)"
13587

13688
.PHONY: clean clobber

0 commit comments

Comments
 (0)