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

Support NFSv4 only environment #617

Merged
merged 4 commits into from
Sep 25, 2023

Conversation

benjamreis
Copy link
Contributor

@benjamreis benjamreis commented May 2, 2023

NFSv4 only environments don't support rpcinfo
and showmount calls as they're missing NFSv3
services.

When rpcinfo or showmount fails, try to mount
NFSv4 pseudo FS '/' to add '4' to supported NFS versions
and run ls on the mounted pseudo FS to offer the first
folder level of exports.

See: #551
And: xcp-ng/xcp#135

@benjamreis
Copy link
Contributor Author

benjamreis commented May 2, 2023

What can be done next:

Attempt a mount on / with nfs4 and:

  • run nfsstat -m to get the version of the mount and add it to the supported version
  • run ls in the mounted / to get some exported paths BUT what if there's multiple level of folders?

What do you think @MarkSymsCtx?

EDIT: Done.

MarkSymsCtx
MarkSymsCtx previously approved these changes May 2, 2023
@MarkSymsCtx
Copy link
Contributor

What can be done next:

Attempt a mount on / with nfs4 and:

  • run nfsstat -m to get the version of the mount and add it to the supported version
  • run ls in the mounted / to get some exported paths BUT what if there's multiple level of folders?

What do you think @MarkSymsCtx?

It's all generally horrible with NFSv4 but the above may help in a significant set of sub-cases.

@benjamreis
Copy link
Contributor Author

Okay, i'll try that then, it's still better than nothing.
Would you prefer to merge this PR 1st and I'll do a 2nd one on top or wait and do everything in this PR?

@stormi
Copy link
Contributor

stormi commented May 2, 2023

run nfsstat -m to get the version of the mount and add it to the supported version

I don't know exactly how this works, but the current version of mount.nfs4 in XS/XCP-ng dom0 defaulted to 4.1 for a server that only supports 4.1 and 4.2. Another client on a more recent computer defaulted to 4.2 for the same server.

This means that the version we can extract from nfsstat -m depends on the client and doesn't give much information about what the server supports, so maybe probe should just reply 4 as the supported version when there's no NFS v3 (Option A).

Another approach would be, after a first successful mount of /, to attempt to mount / with every known version of the v4 protocol (4.0, 4.1, 4.2), and keep only the working values (Option B).

Yet another approach would be always listing all version of NFSv4, and let it fail at sr-create time when the user attempts a not-supported version (Option C).

@benjamreis
Copy link
Contributor Author

benjamreis commented May 2, 2023

Yet another approach would be always listing all version of NFSv4, and let it fail at sr-create time when the user attempts a not-supported version (Option C).

I don't like this option, it can be deceptive to show supported versions and then fail when trying to use them.

IMHO only displaying 4 is enough and let the mount decide on the version?

drivers/nfs.py Outdated Show resolved Hide resolved
drivers/nfs.py Outdated Show resolved Hide resolved
drivers/nfs.py Outdated Show resolved Hide resolved
drivers/nfs.py Show resolved Hide resolved
drivers/nfs.py Outdated Show resolved Hide resolved
@benjamreis benjamreis force-pushed the support-nfsv4-only branch 4 times, most recently from ccf8420 to 58fba7c Compare May 5, 2023 08:28
@benjamreis
Copy link
Contributor Author

Successfull tests on NFS3 & 4.

@olivierlambert
Copy link

Hey :) Any news on this? Is there anything left to do or simply getting validated?



def scan_srlist(path, dconf):
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't particularly like how long this method has now become, it makes it quite cognitively hard to follow. Would be good to pull some of these long open coded blocks out into well named methods which describe what they're doing and then each one can be reviewed and understood in isolation (or ignored if not of interest to the current needs).

Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, to a lesser extent, get_supported_nfs_versions below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can split in methods for NFS3 and NFS4Only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

NFSv4 only environments don't support `rpcinfo`
and `showmount` calls as they're missing NFSv3
services.

When `rpcinfo` or `showmount` fails, try to mount
NFSv4 pseudo FS '/' to add '4' to supported NFS versions
and run `ls` on the mounted pseudo FS to offer the first
folder level of exports.

See: xapi-project#551
And: xcp-ng/xcp#135

Signed-off-by: BenjiReis <[email protected]>
Copy link
Contributor

@MarkSymsCtx MarkSymsCtx left a comment

Choose a reason for hiding this comment

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

Just a minor nit on method names.

Is there anything "useful" to see in the logging for this that will show it working?

drivers/nfs.py Outdated
return dom


def _scan_exports_nfs4_only(target, transport, dom, element):
Copy link
Contributor

Choose a reason for hiding this comment

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

given that we have _scan_exports_nfs3 this should probably just be _scan_exports_nfs4 for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hesitated to add the _only or not, both are okay for me so I can remove it if you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@benjamreis
Copy link
Contributor Author

Is there anything "useful" to see in the logging for this that will show it working?

In a NFS3/NFS3-4 env you should see the same logs as before since NFS4 only is a fallback in case of failure.
In NFS4 only env I added logs saying the 1st method fails and we're trying using the NFS4 pseudo FS
https://github.com/xapi-project/sm/pull/617/files#diff-9ca8a7292c88a517d48db9a9d25ee2d14ffd83f7f40d818c1c4121ce2e275b35R258
https://github.com/xapi-project/sm/pull/617/files#diff-9ca8a7292c88a517d48db9a9d25ee2d14ffd83f7f40d818c1c4121ce2e275b35R346

I also added logs in case both methods failed before throwing an exception.


class NfsException(Exception):

def __init__(self, errstr):
self.errstr = errstr


def check_server_tcp(server, nfsversion=DEFAULT_NFSVERSION):
def check_server_tcp(server, transport, nfsversion=DEFAULT_NFSVERSION):
Copy link
Contributor

Choose a reason for hiding this comment

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

The method is explicit (or is expected to be) in using TCP, so it should not have the transport argument. If get_suppoted_nfs_versions needs a transport it should be passed as a literal from this method without changing the signature of the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed but transport can be tcp or tcp6 in the case of IPv6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you prefer an IPv6 boolean and the the transport given to get_supported_nfs_versions would be 'tcp6' if ipv6 else 'tcp'?

Copy link
Contributor

@MarkSymsCtx MarkSymsCtx Sep 5, 2023

Choose a reason for hiding this comment

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

Ah, I see, that was not clear. Might have been better for the IPv6 bits to be at least a commit on their own right to make it clear. But would be difficult to split now so leave it as it is.

@olivierlambert
Copy link

I think we need another validated reviewer to be able to merge this. Anyone in mind @MarkSymsCtx ?

@MarkSymsCtx
Copy link
Contributor

@olivierlambert I'd already added the extra reviewer

@olivierlambert
Copy link

Can you merge? Thanks!

@KevinLCtx
Copy link

Can you merge? Thanks!

Mark is on vacation I will see if I can find somebody else who has permission to merge it.

@MarkSymsCtx MarkSymsCtx merged commit ba0bd7b into xapi-project:master Sep 25, 2023
2 checks passed
@benjamreis benjamreis deleted the support-nfsv4-only branch September 25, 2023 11:57
benjamreis added a commit to xcp-ng/sm that referenced this pull request Dec 18, 2023
benjamreis added a commit to xcp-ng/sm that referenced this pull request Dec 19, 2023
Wescoeur pushed a commit to xcp-ng/sm that referenced this pull request Feb 6, 2024
Wescoeur pushed a commit to xcp-ng/sm that referenced this pull request Jun 12, 2024
Wescoeur pushed a commit to xcp-ng/sm that referenced this pull request Jun 12, 2024
Wescoeur pushed a commit to xcp-ng/sm that referenced this pull request Oct 3, 2024
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.

5 participants