-
Notifications
You must be signed in to change notification settings - Fork 382
Description
Update to #552 has broken quite some Kubernetes CSI sidecars.
So far I identified two issues:
-
gomock cannot easily compare two messages now. Protobuf now stores some private stuff in
state
field, e.g.NodeGetInfoResponse
:Lines 4827 to 4830 in 2f34062
type NodeGetInfoResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields It is possible to implement a custom gomock matcher that compares just the public fields, or use
proto.Equal
, as suggested in https://protobuf.dev/reference/go/faq/#deepequal. -
It's not possible to copy message content. For example, this code copies value of NodeGetInfoResponse:
nodeInfo, err := ctrl.GetNodeInfo(grpcClient, *operationTimeout) if err != nil { klog.Fatalf("Failed to get node info from CSI driver: %v", err) } nodeDeployment.NodeInfo = *nodeInfo
Such a copy will copy also the private fields and one of the fields is sync.Mutex, which should not be copied (
govet
complains hard about it).
In this particular case, the Kubernetes external-provisioner can use a pointer, it does not need to copy the struct content.
Both issues are solvable using proper protobuf functions (WIP PR here), but they were quite surprising for a minor go package bump.
I am not asking for a revert, just for a better communication of the breaking changes and semantic versioning of go packages. This should not be a minor package bump. There should be probably a separate repo with the generated go code, so we can bump the versions independently on CSI spec. Kubernetes solved this by calling all its go packages 0.x, so no go API stability should be expected, and they break their API from time to time.