-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Separate staging/publish and unstaging/unpublish logics for block #74026
Conversation
Hi @mkimuram. Thanks for your PR. I'm waiting for a kubernetes 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. |
return volumeToMount.GenerateError("MapVolume.EvalHostSymlinks failed", err) | ||
// For in-tree drivers, actual device is attached either in WaitForAttach or SetUpDevice, | ||
// not in MapDevice below, so devicePath could be checked here. | ||
if !isCSI { |
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.
Do you have any better ideas to handle this, so that operation_generator code doesn't need to care whether it is CSI?
We might make SetUpDevice
for CSI return dummy device paht and make all driver resolve symlink from volumeMapPath
below, but I'm not sure if it is better than current one.
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 csi, is the devicePath not the staging path returned by SetUpDevice (NodeStage)?
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 won't be a device in staging path, for csi drivers that don't implement staging and for csi drivers that put other things than a device in staging path. (CSI v1.0 spec allows these two cases.)
The actual device will be available in publish path after MapDevice
is called, by this PR.
/ok-to-test |
// Execute tear down device | ||
unmapErr := blockVolumeUnmapper.TearDownDevice(globalMapPath, deviceToDetach.DevicePath) | ||
// Execute unmap device | ||
unmapErr := blockVolumeUnmapper.UnmapDevice(globalMapPath, deviceToDetach.DevicePath) |
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.
should we call UnmapDevice in the per-pod UnmapVolume instead? Then what if we had all the in-tree plugins called og.blkUtil.UnmapDevice in their plugin.UnmapDevice, and CSI calls Unpublish in its plugin.UnmapDevice
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.
Thank you for pointing it out.
This will be a big change, so I wanted to make an agreement before go ahead.
I will try implementing this way and update the commit.
pkg/volume/csi/csi_block.go
Outdated
// Call NodePublishVolume | ||
stagingPath := m.getStagingPath() |
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.
should this be getPublishPath? currently getPublishPath is unused
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.
Staging path is used here for publish call, it is due to CSI spec.
It's confusing, so I agree that we should change publishVolumeForBlock
not to take stagingPath
as an argument, and get it inside the function, as it is done for publishPath
.
return volumeToMount.GenerateError("MapVolume.EvalHostSymlinks failed", err) | ||
// For in-tree drivers, actual device is attached either in WaitForAttach or SetUpDevice, | ||
// not in MapDevice below, so devicePath could be checked here. | ||
if !isCSI { |
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 csi, is the devicePath not the staging path returned by SetUpDevice (NodeStage)?
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.
Thank you for your comment.
I will update the commit as suggested.
return volumeToMount.GenerateError("MapVolume.EvalHostSymlinks failed", err) | ||
// For in-tree drivers, actual device is attached either in WaitForAttach or SetUpDevice, | ||
// not in MapDevice below, so devicePath could be checked here. | ||
if !isCSI { |
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 won't be a device in staging path, for csi drivers that don't implement staging and for csi drivers that put other things than a device in staging path. (CSI v1.0 spec allows these two cases.)
The actual device will be available in publish path after MapDevice
is called, by this PR.
// Execute tear down device | ||
unmapErr := blockVolumeUnmapper.TearDownDevice(globalMapPath, deviceToDetach.DevicePath) | ||
// Execute unmap device | ||
unmapErr := blockVolumeUnmapper.UnmapDevice(globalMapPath, deviceToDetach.DevicePath) |
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.
Thank you for pointing it out.
This will be a big change, so I wanted to make an agreement before go ahead.
I will try implementing this way and update the commit.
pkg/volume/csi/csi_block.go
Outdated
// Call NodePublishVolume | ||
stagingPath := m.getStagingPath() |
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.
Staging path is used here for publish call, it is due to CSI spec.
It's confusing, so I agree that we should change publishVolumeForBlock
not to take stagingPath
as an argument, and get it inside the function, as it is done for publishPath
.
Updated as suggested. PTAL Note that ref-counting and releasing descriptor lock codes are also moved to CSI's |
df3a8da
to
2ceee60
Compare
437d1cc
to
5d7e7c5
Compare
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
I've created #84625 to separate the commits and explain the intention of the code to each commit comment. This is still work in progress, because no logic change from this PR's version, so I will continue working on to change the code per your comments. I hope that above PR at least answer to your two comments below:
I would appreciate it if you could suggest me how we separate it to small PRs. (Should it be per commit in #84625?) |
I don't really understand 100% what's happening enough to have suggestions on how to split this up into smaller PRs. It may be that the answer is it can't and some commit separation is helpful enough for review :) I'm just concerned since theres a lot of code moving around and it's not clear which parts are refactoring and which are net-new. The PR title says logic is being "seperated" but I see some completely new functions with significant logic. It might be worth seperating out the refactor into one PR where things just move around, and another PR for each of the issues that need to be fixed |
Thank you for your comment. I think that the last three commits in #84625 is actually separating the logic as described in the PR tittle, and other commits are prerequisite for it. So, let's split them into two, and split them more if needed. Edit:
They should be merged with above order. |
e1ce3fd
to
136ce69
Compare
Rebased again on top of #84747 after #84660 is merged. Waiting for #84747 to be merged. Can this also be targeted to 1.17? (Although, @jsafrane 's time zone is already midnight.) The last discussion for this PR is #84625 (comment) . I'm pushing the latest version here, so that we can compare this PR and #84625 . I believe that this PR should be ready to be merged, if others agree.) Any comments? @davidz627 @msau42 @jingxu97 |
Now #84747 is merged. I will rebase this PR with the latest master. |
This change is to allow CSI driver to publish the same volume for multipe pods on the same node.
136ce69
to
4578c6c
Compare
Rebased. Now it should be ready to be merged. PTAL |
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
/milestone v1.17
/priority important-soon |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mkimuram, saad-ali 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 |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR changes staging/publish and unstaging/unpublish logics for block to be called from separate methods. Also, publish path is changed to per pod path from per volume path.
[Before]
stageVolumeForBlock
: called fromSetupDevice
publishVolumeForBlock
: called fromSetupDevice
unstageVolumeForBlock
: called fromTearDownDevice
unpublishVolumeForBlock
: called fromTearDownDevice
plugins/kubernetes.io/csi/volumeDevices/publish/{pvname}
[After]
stageVolumeForBlock
: called fromSetupDevice
publishVolumeForBlock
: called fromMapDevice
unstageVolumeForBlock
: called fromTearDownDevice
unpublishVolumeForBlock
: called fromUnmapDevice
plugins/kubernetes.io/csi/volumeDevices/publish/{pvname}/{podUid}
Summary of discussion why this change needed is commented here
Which issue(s) this PR fixes:
Fixes #73773
Special notes for your reviewer:
/sig storage
@bswartz @msau42 @wongma7 @vladimirvivien
Does this PR introduce a user-facing change?: