Skip to content

Switch to using google.golang.org/protobuf rather than github.com/golang/protobuf #829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/evanphx/json-patch v4.12.0+incompatible
github.com/fsnotify/fsnotify v1.6.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
github.com/google/gofuzz v1.2.0
github.com/kubernetes-csi/csi-lib-utils v0.12.0
github.com/kubernetes-csi/csi-test/v4 v4.0.2
Expand All @@ -17,6 +16,7 @@ require (
github.com/prometheus/common v0.37.0
github.com/spf13/cobra v1.6.1
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
k8s.io/api v0.27.0
k8s.io/apimachinery v0.27.0
k8s.io/client-go v0.27.0
Expand All @@ -38,6 +38,7 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, it is still pulled in as an indirect dependency by a number of other components.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xing-yang Any chance this can be approved? I removed the explicit dependency on github.com/golang/protobuf; the remaining indirect reference comes from other components that still use github.com/golang/protobuf.
If I am missing other steps that I should do as part of this PR to remove the indirect dependency, please let me know. Thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check who is making this indirect dep? You can try this "go mod why -m ".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it is being pulled in by github.com/container-storage-interface/spec/lib/go/csi

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking!

github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand All @@ -61,7 +62,6 @@ require (
golang.org/x/time v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect
google.golang.org/protobuf v1.28.1 // 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
Expand Down
12 changes: 3 additions & 9 deletions pkg/snapshotter/snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/protobuf/ptypes"
csirpc "github.com/kubernetes-csi/csi-lib-utils/rpc"

"google.golang.org/grpc"
Expand Down Expand Up @@ -74,10 +73,8 @@ func (s *snapshot) CreateSnapshot(ctx context.Context, snapshotName string, volu
}

klog.V(5).Infof("CSI CreateSnapshot: %s driver name [%s] snapshot ID [%s] time stamp [%v] size [%d] readyToUse [%v]", snapshotName, driverName, rsp.Snapshot.SnapshotId, rsp.Snapshot.CreationTime, rsp.Snapshot.SizeBytes, rsp.Snapshot.ReadyToUse)
creationTime, err := ptypes.Timestamp(rsp.Snapshot.CreationTime)
if err != nil {
return "", "", time.Time{}, 0, false, err
}

creationTime := rsp.Snapshot.CreationTime.AsTime()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any error check for this? Could "creationTime" be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AsTime() method returns a time.Time struct (not an interface or pointer) which cannot be nil, and since the method does not return an error, there is nothing to error check.

return driverName, rsp.Snapshot.SnapshotId, creationTime, rsp.Snapshot.SizeBytes, rsp.Snapshot.ReadyToUse, nil
}

Expand Down Expand Up @@ -138,9 +135,6 @@ func (s *snapshot) GetSnapshotStatus(ctx context.Context, snapshotID string, sna
return false, time.Time{}, 0, fmt.Errorf("can not find snapshot for snapshotID %s", snapshotID)
}

creationTime, err := ptypes.Timestamp(rsp.Entries[0].Snapshot.CreationTime)
if err != nil {
return false, time.Time{}, 0, err
}
creationTime := rsp.Entries[0].Snapshot.CreationTime.AsTime()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response same as above, AsTime() doesn't return a nillable type or an error to check.

return rsp.Entries[0].Snapshot.ReadyToUse, creationTime, rsp.Entries[0].Snapshot.SizeBytes, nil
}
16 changes: 5 additions & 11 deletions pkg/snapshotter/snapshotter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/mock/gomock"
"github.com/golang/protobuf/ptypes"
"github.com/kubernetes-csi/csi-lib-utils/connection"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
"github.com/kubernetes-csi/csi-test/v4/driver"

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -68,11 +68,8 @@ func createMockServer(t *testing.T) (*gomock.Controller, *driver.MockCSIDriver,
func TestCreateSnapshot(t *testing.T) {
defaultName := "snapshot-test"
defaultID := "testid"
createTimestamp := ptypes.TimestampNow()
createTime, err := ptypes.Timestamp(createTimestamp)
if err != nil {
t.Fatalf("Failed to convert timestamp to time: %v", err)
}
createTimestamp := timestamppb.Now()
createTime := createTimestamp.AsTime()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response same as above, AsTime() doesn't return a nillable type or an error to check.


createSecrets := map[string]string{"foo": "bar"}
defaultParameter := map[string]string{
Expand Down Expand Up @@ -338,11 +335,8 @@ func TestDeleteSnapshot(t *testing.T) {
func TestGetSnapshotStatus(t *testing.T) {
defaultID := "testid"
size := int64(1000)
createTimestamp := ptypes.TimestampNow()
createTime, err := ptypes.Timestamp(createTimestamp)
if err != nil {
t.Fatalf("Failed to convert timestamp to time: %v", err)
}
createTimestamp := timestamppb.Now()
createTime := createTimestamp.AsTime()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response same as above, AsTime() doesn't return a nillable type or an error to check.


defaultRequest := &csi.ListSnapshotsRequest{
SnapshotId: defaultID,
Expand Down