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
CSI fix for gRPC conn leak #64519
CSI fix for gRPC conn leak #64519
Conversation
/sig storage |
/milestone v1.11 @kubernetes/sig-storage-pr-reviews please see if the milestone/priority is correct |
/test pull-kubernetes-e2e-kops-aws |
return nil, fmt.Errorf("driver name is empty") | ||
} | ||
|
||
network := "unix" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about defining network
as a const at the top of the file? I think it would be more visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, the value for network does not need to be global since it should always be "unix" and is only used when constructing the connection in that method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments
@@ -61,45 +62,13 @@ type csiClient interface { | |||
|
|||
// csiClient encapsulates all csi-plugin methods | |||
type csiDriverClient struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a struct interface implementation check:
var _ csiClient = &csiDriverClient{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if err := c.assertConnection(); err != nil { | ||
glog.Errorf("%v: failed to assert a connection: %v", csiPluginName, err) | ||
|
||
conn, err := newGrpcConn(c.driverName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as a general rule of thumb never call new
anything inside of a method implementing business logic. That encodes the creation of a dependency with the business logic making it harder to test just the business logic.
Instead, have the dependency either passed in as a parameter (with an interface type) or make the method creating the external dependency another interface method (i.e. a new NewGrpcConnection()
method in the csiClient interface
). That way it makes it easy to create a fake of the dependency for testing.
You don't have to do this now. Can do it in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will take a look at that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i looked at your suggestion. While agree, I even had an impl that injected the connection. However, the grpc.ClientConn
type (created with newGrpcCon) is a struct value which complicates mocking it. So, I kept it simple. But I agree.
@@ -290,29 +291,12 @@ func (c *csiMountMgr) TearDownAt(dir string) error { | |||
return nil | |||
} | |||
|
|||
// load volume info from file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this code being moved to NewUnmounter()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up, why isn't saveVolumeData(...)
also being moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialization of csiClient
is moved to New{Moun|Unmoun}ter
to keep value injection of csiMounterMgr
consistent and in one location, where possible. This also helps clean the method of non-storage code. I agree, saveVolumeData
probably should be moved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, saveVolumeData
will stay. This is because it's called in the SetUpAt()
method after the mount dir its created which is the location where the json file is saved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's open up a an issue to clean this up later. It's really odd that save is done in one location and load is done in a completely different place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you pointed it out, I could not resist to make things more uniformed. Good suggestion (included a bit of clean up too) Done.
/test pull-kubernetes-e2e-gce-device-plugin-gpu |
/test pull-kubernetes-e2e-gce |
/test pull-kubernetes-e2e-gce-device-plugin-gpu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
|
||
return nil | ||
func newCsiDriverClient(driverName string) *csiDriverClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: return the interface (csiClient
) not the struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I missed that.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: saad-ali, vladimirvivien The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/status approved-for-milestone |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process Pull Request Labels
|
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
…f-#64519-upstream-release-1.10 Automatic merge from submit-queue. Automated cherry pick of #64519: CSI fix for gRPC conn leak, test updates Cherry pick of #64519 on release-1.10. #64519: CSI fix for gRPC conn leak, test updates ```release-note Fixed CSI gRPC connection leak during volume operations. ```
What this PR does / why we need it:
This PR is a bug fix for leaky gRPC connection that never closes (see issue #64341 for detail)
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #64341
This fix was originally started with PR #64380