-
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
Attacher/Detacher refactor for local storage #66884
Attacher/Detacher refactor for local storage #66884
Conversation
@@ -294,6 +294,10 @@ func (plugin *TestPlugin) NewAttacher() (volume.Attacher, error) { | |||
return &attacher, nil | |||
} | |||
|
|||
func (plugin *TestPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { | |||
return plugin.NewAttacher() |
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.
Hm, I wonder if this would cause any issues for attachable plugins if they had been keeping some state in the Attacher object.
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.
The refactor move MountDevice()
and GetDeviceMountPath()
from Attacher
to DeviceMounter
.
The difference is:
Before this change: we will create an Attacher
and let it call WaitForAttach
, GetDeviceMountPath()
and MountDevice()
After this change: we will create an Attacher
and a DeviceMounter
, let Attacher
call WaitForAttach
, let DeviceMounter
call GetDeviceMountPath()
and MountDevice()
.
Here, It seems that GetDeviceMountPath()
and MountDevice()
will not change the state kept in Attacher object(which is attachedVolumeMap
), and also the ErrorEncountered
will not affect the logic, since we will return directly if error occurs
BTW: for now, we will create a new Attacher
in both GenerateMountVolumeFunc
and GenerateAttachVolumeFunc
which are called by different components. It seems that we should avoid keeping state in Attacher object.
please correct me if i am wrong.
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'm worried about situations where a plugin may have kept some state to serialize between WaitForAttach and MountDevice, like a lock or some cached data.
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.
Got it, for now, i can not find the state kept between WaitForAttach and MountDevice through the plugins.
But should we cache the attacher info for the situations you are worried about ? e.g. if the attacher is created before, we do not need to create a new one in NewDeviceMounter...
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 went through volume plugins, none of them really passes information from WaitForAttach to MountDevice via the attacher instance.
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.
Thanks guys for searching! This sounds fine to me then.
I quickly went through the PR and I like it. |
|
||
// DeviceMounter can mount a block volume to a global path. |
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.
Can we drop block volume
word from here? it seems iffy - there are block volumes which don't necessarily use DeviceMounter
and there could be non-block volumes that use the interface?
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 are block volumes which don't necessarily use DeviceMounter
which is true, for block mode.
there could be non-block volumes that use the interface
Actually, for now, local storage is the only use case that we only implement DeviceMounter( not implement Attacher interface).
We will only mount block device to a global path. If the local storage is a fs dir, we will do nothing, just set global path to its Path
in pv spec.
minor nit but otherwise lgtm! |
@@ -294,6 +294,10 @@ func (plugin *TestPlugin) NewAttacher() (volume.Attacher, error) { | |||
return &attacher, nil | |||
} | |||
|
|||
func (plugin *TestPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { | |||
return plugin.NewAttacher() |
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.
Thanks guys for searching! This sounds fine to me then.
@@ -725,13 +734,31 @@ func (og *operationGenerator) GenerateUnmountDeviceFunc( | |||
return volumetypes.GeneratedOperations{}, deviceToDetach.GenerateErrorDetailed("UnmountDevice.FindAttachablePluginBySpec failed", err) | |||
} | |||
|
|||
volumeDetacher, err := attachableVolumePlugin.NewDetacher() | |||
// Get DeviceMounter plugin |
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 we still need to get attachable plugin above?
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.
Also, how does the caller of this detect if the plugin is device mountable?
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 we still need to get attachable plugin above?
we don't need it now, thanks, i will remove it
Also, how does the caller of this detect if the plugin is device mountable?
The UnmountDevice func is only called when the volume mode is Filesystem and we find the attachedVolume is globally mounted , which is set true in MarkDeviceAsMounted
. Which means the plugin is device mountable.
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, just want to make sure that this attachedVolume
doesn't actually require AttachablePlugin?
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 think so.
If the volume does not implement the attacher interface, it is assumed to be attached and the actual state of the world is updated accordingly.
see: https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/util/operationexecutor/operation_executor.go#L133
@@ -478,35 +478,45 @@ func (og *operationGenerator) GenerateMountVolumeFunc( | |||
volumeAttacher, _ = attachableVolumePlugin.NewAttacher() | |||
} | |||
|
|||
// get deviceMounter, if possible | |||
deviceMountableVolumePlugin, _ := og.volumePluginMgr.FindDeviceMountablePluginBySpec(volumeToMount.VolumeSpec) |
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.
Can you add unit tests for these new plugin scenarios?
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 not sure i understand the scenarios
. Just added some UTs for Concurrent Mount operations for devicemountable plugins in the third commit. PTAL, thanks
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 mean adding test cases for DeviceMountable-only plugins for Mount and Unmount To ensure that we have correctly decoupled the attacher
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.
We haven't implemented any DeviceMountable-only plugins for now, this PR is just interface refactor. We can add these UTs in my another PR: #63011
WDYT ?
9e9374e
to
bc15887
Compare
bc15887
to
55784f8
Compare
/retest |
Errors seem not related to this change /retest |
/lgtm |
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jsafrane, msau42, NickrenREN, 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 |
/retest |
/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. |
Proposal link: kubernetes/community#2438
What this PR does / why we need it:
Attacher/Detacher refactor for the plugins which just need to mount device, but do not need to attach, such as local storage plugin.
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 #
Special notes for your reviewer:
/sig storage
/kind feature