-
Notifications
You must be signed in to change notification settings - Fork 54
Improve NodePublishVolume and NodeStageVolume #463
Conversation
ad3d2d6
to
921dd63
Compare
I just realized that if Capability/mount_flags are present in NodePublishVolume request, current code never uses those in mounting. |
921dd63
to
c49f571
Compare
f345e91
to
7e61623
Compare
Removed test-repeater part which was present only for testing, and WIP. |
7e61623
to
aaa4343
Compare
pkg/pmem-csi-driver/nodeserver.go
Outdated
@@ -42,7 +43,12 @@ type nodeServer struct { | |||
nodeCaps []*csi.NodeServiceCapability | |||
cs *nodeControllerServer | |||
// Driver deployed to provision only ephemeral volumes(only for Kubernetes v1.15) | |||
mounter mount.Interface | |||
mounter mount.Interface | |||
volReadOnly map[string]bool |
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.
How about introducing a new structure and keeping all these new params as fields in it. Then we can maintain a single VolumeId:Params
map, easy to maintain. If I remember correctly we used to have such type earlier but removed as found no real need that time.
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.
yes, good idea. I started with that, but I realized now the creation and deletion happen in two places, so we can not just conveniently get rid of whole map entry in one place.
Another related question arises: I added map for fsType, which is there now for completeness, but is not actually used. This part is created and used in different function.
Can we perhaps leave fsType out, the we can have one map handling in single 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.
creation and deletion happen in two places, so we can not just conveniently get rid of whole map entry in one place.
Yes, If I understood correctly the change, the two possible places depend on type of volume: ephemeral or persistent. So for persistent volumes the point of creation/deletion of map entry in Stage/Unstage and for ephemeral its publish/unpublish. We can even store the volume type in that map so that it's easy to check when to delete the entry from the cache and even we can avoid these workarounds for ephemerals.
pkg/pmem-csi-driver/nodeserver.go
Outdated
mountFlags := req.GetVolumeCapability().GetMount().GetMountFlags() | ||
readOnly := req.GetReadonly() | ||
fsType := req.GetVolumeCapability().GetMount().GetFsType() | ||
klog.V(3).Infof("NodePublishVolume request: VolID:%s targetpath:%v sourcepath:%v readonly:%v Capab/mountflags:%v Capab/fsType:%v", |
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 change Capab/mountflags
to mount flags:
in the log message. Capab is not informative.
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.
Changed in current code, just pushed
pkg/pmem-csi-driver/nodeserver.go
Outdated
// before storing: sort mountFlags slice and join to become single string, as this is what we use to compare | ||
askedFlags := req.GetVolumeCapability().GetMount().GetMountFlags() | ||
sort.Strings(askedFlags) | ||
joinedAskedFlags := strings.Join(askedFlags[:], ",") |
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 code duplication, that we can avoid by reusing the already prepared mount flags array here: fd89169#diff-4a0caa0c2e37db715640b7cbf97d7a1fR212-R214
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 code above is inside if-block so it is not guaranteed it has created that value.
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 we move that computation above the "if" so that it happens always once?
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 we move that computation above the "if" so that it happens always once?
Yes I think, as we always store that info anyway.
pkg/pmem-csi-driver/nodeserver.go
Outdated
@@ -374,6 +413,7 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag | |||
return nil, err | |||
} | |||
|
|||
ns.volFstype[req.VolumeId] = "" |
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.
When exactly we clean/remove the cache cahced map(s) elements?
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, indeed I should use delete() instead of just overwriting with empty, added delete() calls in latest code.
pkg/pmem-csi-driver/nodeserver.go
Outdated
// Means, we check only mountflags part of Capability. | ||
// Mount flags are coded as []string, so we sort and join mount flags to single string | ||
// for easier comparing. | ||
// We do not check VolumeCapability/fsType as fsType may be missing (is used in NodeStageVolume). |
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.
These remvoed comments are added part of this PR, I feel like you can squash with your earlier commit which introduced these comments. I am ok to completely sqashing this commit too.
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, yes I had changed in later commit that I had created in previous one. I now combined the changes of text-changing commit into previous bigger commit.
aaa4343
to
452ea5a
Compare
addressed recent commits, force-pushed, also e2e testing that code locally while CI is not yet functioning. |
We have good CI results for this one. @avalluri, is it okay to merge? |
452ea5a
to
c7e5a7c
Compare
I pushed a version where mountflags sorting for storing is made above "if" to have single instance of that code. |
c7e5a7c
to
44fa0b4
Compare
pushed with added code to compare also fsType, but only if present in request. |
44fa0b4
to
e071b3b
Compare
pushed new version where main improvement commit is changed so that it get fsType from device instead of storing in map. |
e071b3b
to
40337da
Compare
pushed a new version again, checking of existing file system is moved out from ProvisionDevice. |
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, @okartau . Few things in my mind:
- current code is not considering the mount flags in stage volume for repeated mounts.
- I feel instead of caching mount flags, we should retrieve that information from the existing mount point as we are doing that from
fsType
. We should change our logic of determining the existing filesystem of a mount path. Currently, we are retrieving that information usingfile
andblkid
. Instead, if we can retrieve both mount flags and fstype from procfs.
I am ok to merge this now, do the changes as a separate PR.
As this CI failure here demonstrates (and also failure on #453 after rebase), recent change to strictly forcing vendor/ state takes away method that I use for development purposes: having local changes in devel/, but only in PR, not to be merged. I combine such changes with other PRs to generate a state with those changes that are not (yet) upstreamed. Is this how we want it, (i.e. we cant put changes through CI with intentional vendor/ changes that we know of but we plan not to check in), or could we have some method to work around that check? |
Olev Kartau <notifications@github.com> writes:
I understand this protects us against unintentional vendor/ changes,
but what about intentional.
Remove the "make test" step in the Jenkinsfile?
|
Tried that in #453 but it fails in dm-test. Does dm-test depend on something that happens in 'make test' ? It's not that obvious from output what went wrong, or is it for experienced eye... |
faile at the |
you mean failure was independent of skip of 'make test' step ? and it could work when retried? |
It should but, |
b87a6f9
to
3830935
Compare
3830935
to
a7819fe
Compare
CI success in combination with repeated tests, removing WIP and repeating-dev-debug commits, force pushed |
a7819fe
to
d445884
Compare
A log message has gone missing in some previous commit.
Return FailedPrecondition if stagingtargetpath not set
If a volume is already mounted, we must check are the parameteres compatible, and return OK if they are. For having something to compare, we have to store params on Publish. Use sorted and converted to single string mount options in compare. Start with mount options given in request, instead of empty, to take given options into use if present. fsType is not stored in settings, but detected from device.
There may be mount options present in request, so let's start with that set instead of empty.
This check is needed only if called from StageVolume, so lets make it in StageVolume, giving possibility to return API error codes that follow spec better.
d445884
to
d13ec74
Compare
Is this ready for merging or does it need another round of review by @avalluri? |
It can be merged., but needs a follow-up PR to cover the points mentioned here #463 (review) |
I created issue #483, will merge this. |
NodePublishVolume performs checks for attributes compatibility if volume already mounted.
If StagingTargetPath is not set, return FAILED_PRECONDITION.
Resolves: #462
Resolves: #465