-
Notifications
You must be signed in to change notification settings - Fork 62
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
Close Open disk file handles #126
Conversation
Hi @wongma7. Thanks for your PR. I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
@wongma7 could you address the comment? |
/lgtm |
/assign @msau42 please approve! 2 liner PR! many thanks! |
internal/os/disk/api.go
Outdated
@@ -254,6 +254,7 @@ func (imp APIImplementor) GetDiskNumberWithID(page83ID string) (uint32, error) { | |||
|
|||
for i := range disks { | |||
h, err := syscall.Open(disks[i].Path, syscall.O_RDONLY, 0) | |||
defer syscall.Close(h) |
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's the maximum number of disks a node can have? Would it be worth enclosing this loop in a code section so that it gets closed at the end of each loop?
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.
for ec2 depends on instance type but typically like 20-30
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/volume_limits.html#instance-type-volume-limits (EKS only supports windows nitro instances so the "AWS PV" driver in the other section don't apply)
do you mean to wrap it like this? I don't think it's worth the loss in readability
func() (uint32, error) {
...
syscall.Open
defer syscall.Close(h)
}()
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.
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.
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.
did some refactoring so we always open and close 1 handle at a time
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wongma7 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold need to retest on my setup |
@wongma7 thanks for this PR. Pls let me know after you test it. |
/hold cancel together with #145 I tested that attach, mount, unmount, detach works with ebs |
} | ||
} | ||
|
||
return 0, fmt.Errorf("Could not find disk with Page83 ID %s", page83ID) | ||
} | ||
|
||
var ErrNotFound = errors.New("not found") | ||
|
||
func (imp APIImplementor) getDiskNumberByID(path string, page83ID string) (uint32, error) { |
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 am kind of confused by these two functions getDiskNumberAndIDByPath and getDiskNumberByID.
Is there a way to kind of combine those?
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.
okay, let me combine.
(the PR started as 2 lines, bit by bit it has ballooned, so I am getting confused too 😂)
@mauriciopoppe is working on disk API part #140 |
@jingxu97 I'm going to revert to the original PR where I just call syscall.Close(h) at end of the loop. I don't want to refactor and then rebase if beta3 API will make it obsolete |
What type of PR is this?
/kind bug
What this PR does / why we need it:
If csi-proxy keeps these files open it blocks EBS detach from succeeding.
I tested this fix and it works for me.
Full story:
While debugging my EBS CSI implementation I found everything worked fine except for volume Detach. EBS support said OS was reporting something holding on to the disk (despite me trying removing all accesspoints, taking disk offline, etc.). Eventually after much guessing and testing, narrowed it to csi-proxy, i.e. as soon as I stopped it Detach would proceed. (I'm no Windows expert so possibly there was an easier way to find out what was holding onto device, like via process explorer, but yeah...)
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: