Skip to content
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: Allow NodePublishVolume even when plugin does not support staging #3116

Merged
merged 2 commits into from
Feb 17, 2023

Conversation

olljanat
Copy link
Contributor

@olljanat olljanat commented Feb 5, 2023

- What I did
I was packing NFS CSI for Swarm on https://github.com/olljanat/csi-plugins-for-docker-swarm/tree/master/csi-driver-nfs when noticed that it was able to create volume and folder to NFS share but mounting volume to didn't worked but instead of it ended up looping these messaged on Docker engine log:

INFO[2023-02-04T19:21:08.939610819+01:00] attempting to publish volume                  attempt=1 module=node/agent/csi volume.id=0f9wq7wvz41wxw81u4gfsiy55
DEBU[2023-02-04T19:21:08.939765667+01:00] staging volume succeeded, attempting to publish volume  attempt=1 module=node/agent/csi volume.id=0f9wq7wvz41wxw81u4gfsiy55
INFO[2023-02-04T19:21:08.939788029+01:00] publishing volume failed                      attempt=1 error="rpc error: code = FailedPrecondition desc = volume not staged" module=node/agent/csi volume.id=0f9wq7wvz41wxw81u4gfsiy55

- How I did it
Set stagingPath to empty string by default and continue logic instead of return error when plugin does not support staging.

- How to test it
Added another test case without staging. Manual testing can be done with linked NFS CSI plugin.

- Description for the changelog

@s4ke
Copy link
Contributor

s4ke commented Feb 7, 2023

+1 on this.

The Hetzner CSI plugin I am working on does not support staging either:

func (s *NodeService) NodeStageVolume(ctx context.Context, req *proto.NodeStageVolumeRequest) (*proto.NodeStageVolumeResponse, error) {
	return nil, status.Error(codes.Unimplemented, "not supported")
}

func (s *NodeService) NodeUnstageVolume(ctx context.Context, req *proto.NodeUnstageVolumeRequest) (*proto.NodeUnstageVolumeResponse, error) {
	return nil, status.Error(codes.Unimplemented, "not supported")
}

@crazy-max
Copy link
Member

crazy-max commented Feb 7, 2023

We got an issue with CI and fix had been merged, can you rebase please?

@olljanat olljanat force-pushed the csi-allow-publish-without-staging branch 2 times, most recently from a73eb42 to 3188914 Compare February 7, 2023 16:34
@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2023

Codecov Report

Merging #3116 (50ca5ad) into master (8892b33) will increase coverage by 61.78%.
The diff coverage is 75.00%.

❗ Current head 50ca5ad differs from pull request most recent head 1ab7f13. Consider uploading reports for the commit 1ab7f13 to get more accurate results

@@             Coverage Diff             @@
##           master    #3116       +/-   ##
===========================================
+ Coverage        0   61.78%   +61.78%     
===========================================
  Files           0      153      +153     
  Lines           0    31023    +31023     
===========================================
+ Hits            0    19167    +19167     
- Misses          0    10317    +10317     
- Partials        0     1539     +1539     

@olljanat olljanat force-pushed the csi-allow-publish-without-staging branch from 849c087 to 7714771 Compare February 7, 2023 17:02
@olljanat
Copy link
Contributor Author

olljanat commented Feb 7, 2023

@crazy-max yes, CI started working with rebase and found two issues which I needed to solve ( accessMode cannot be nil and there need to be separate test case with and without staging).

@dperny PTAL

Copy link
Member

@neersighted neersighted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things we'd like to see changed after a peer session with @dperny.

agent/csi/plugin/plugin.go Outdated Show resolved Hide resolved
agent/csi/plugin/plugin_test.go Outdated Show resolved Hide resolved
@@ -290,6 +290,9 @@ func (np *nodePlugin) NodePublishVolume(ctx context.Context, req *api.VolumeAssi
if len(req.VolumeID) == 0 {
return status.Error(codes.InvalidArgument, "Volume ID missing in request")
}
if req.AccessMode == nil {
return status.Error(codes.InvalidArgument, "AccessMode missing in request")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's factor this out into a common helper and use it in the Stage/Unstage methods as well (every method that calls makeCapability). I'd also like to see that change in a separate commit.

@olljanat olljanat force-pushed the csi-allow-publish-without-staging branch 3 times, most recently from a63fdbf to 50ca5ad Compare February 13, 2023 22:53
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
@olljanat olljanat force-pushed the csi-allow-publish-without-staging branch from 50ca5ad to 1ab7f13 Compare February 13, 2023 23:03
@olljanat
Copy link
Contributor Author

@neersighted I was not sure what would be correct location for that helper and when started working with it I found that makeCapability function did exists twice so I introduced pkg/... structure for swarmkit too as it looks to be quite common way 😄

@neersighted
Copy link
Member

neersighted commented Feb 13, 2023

I think the pkg pattern has been quite detrimental overall; if we need to share things across two packages I'd suggest we use internal/ instead (so otherwise exported fields are kept from being public).

@olljanat olljanat force-pushed the csi-allow-publish-without-staging branch from 1ab7f13 to 44a6397 Compare February 13, 2023 23:31
@olljanat olljanat force-pushed the csi-allow-publish-without-staging branch 2 times, most recently from 19d3a0d to b9c07e4 Compare February 13, 2023 23:48
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
@olljanat olljanat force-pushed the csi-allow-publish-without-staging branch from b9c07e4 to bd7d9d8 Compare February 14, 2023 00:19
@olljanat
Copy link
Contributor Author

Now those are in internal/csi/capability and CI is green (looks to be flaky if you update PR when CI is not ready from earlier run).

@neersighted
Copy link
Member

capability is really not a great home for these, but I think that's a bikeshed we can worry about later -- most of these helpers should probably go into a apihelpers or typeconversion or something package that has its own unit tests.

I think this LGTM to me overall, I'll sync up with @dperny again to go over it once we both have bandwidth.

@dperny
Copy link
Collaborator

dperny commented Feb 17, 2023

Not a blocker on this PR, but we should move the volumequeue package from the top level into internal/csi/volumequeue. Not sure why I didn't think of that in the first place.

@dperny dperny merged commit 2ad26e5 into moby:master Feb 17, 2023
lukasmetzner pushed a commit to hetznercloud/csi-driver that referenced this pull request Oct 10, 2024
…cker swarm

With the merge of moby/swarmkit#3116 the mock staging/unstaging is not needed anymore. It was introduced in our csi-driver in this commit: 619fa5c. Which is part of a large PR (squashed commit) that included experimental support for Docker swarm.
lukasmetzner added a commit to hetznercloud/csi-driver that referenced this pull request Oct 18, 2024
)

With the merge of moby/swarmkit#3116 the mock
staging/unstaging is not needed anymore. It was introduced in our
csi-driver in this commit:
619fa5c.
Which is part of a large PR (squashed commit) that included experimental
support for Docker swarm.

See:
- #376 
- #382

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants