-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fix NFS VolumeStore FQDN not working #8244
Conversation
lib/tether/ops_linux.go
Outdated
|
||
log.Debugf("Looking up host %s", source.Hostname()) | ||
ips, err := net.LookupIP(source.Hostname()) | ||
if err != nil { | ||
log.Errorf("mounting %s on %s failed: %s", source.String(), target, err) |
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.
Could we update this error message to specify looking up the IP for the specified hostname failed? It seems like that might be useful context to provide to aid in debugging, as that might lead to different troubleshooting steps than focusing on the mounting process itself.
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've thought that the variable 'err' contains corresponding looking-up failure info
return nil | ||
} | ||
} | ||
log.Errorf("mounting %s on %s failed: %s", source.String(), target, err) |
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.
If there are multiple IPs, we'll only log the last error to occur. Maybe it would be helpful to log each error (and the associated IP address) at DEBUG within the loop, in addition to this ERROR-level log message here.
lib/tether/ops_linux.go
Outdated
//We resolve the ip address nearest the mounting action. | ||
//An alternative place is nfs.CreateMountSpec function in /lib/portlayer/storage/nfs/vm.go | ||
mountOptionsFQDN2IP := strings.Replace(mountOptions, source.Hostname(), ip.String(), -1) | ||
if err = Sys.Syscall.Mount(rawSource.String(), target, nfsFileSystemType, syscall.MS_NOATIME, mountOptionsFQDN2IP); err == nil { |
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.
Could we extract this call to Sys.Syscall.Mount
into a private method that takes rawSource
, target
, nfsFileSystemType
, and the mountOptions*
? This would let us avoid duplication with the identical call above and, more importantly, ensure that we keep the behavior between IP- and hostname-based handling consistent (e.g., if we ever replaced syscall.MS_NOATIME
or made it configurable — as the comment above suggests we might).
lib/tether/ops_linux.go
Outdated
//NOTE: the mountOptions of syscall mount only accept addr=ip; addr=FQDN doesn't work | ||
//We resolve the ip address nearest the mounting action. | ||
//An alternative place is nfs.CreateMountSpec function in /lib/portlayer/storage/nfs/vm.go | ||
mountOptionsFQDN2IP := strings.Replace(mountOptions, source.Hostname(), ip.String(), -1) |
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.
It seems like rawSource.String()
will also contain the hostname. Does that need to be replaced 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.
Actually hostname in rawSource.String() doesn't affect sys.syscall.mount.
cc4f6f6
to
17f04ff
Compare
The fix looks good. I've been trying to think of a way to add testing before approving. |
lib/tether/ops_linux.go
Outdated
for _, ip := range ips { | ||
//NOTE: the mountOptions of syscall mount only accept addr=ip. addr=FQDN doesn't work | ||
//We resolve the ip address nearest the mounting action. | ||
mountOptionsIP := strings.Replace(mountOptions, source.Hostname(), ip.String(), -1) |
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.
Are there edge cases where mountOptions
could contain the source.Hostname()
multiple times? Could someone provide a source.Hostname()
like addr
(a valid hostname, but not a valid FQDN) that actually appears as a key in addition to being a value)?
Maybe prefixing the old/new with addr=
would reduce risk here?
strings.Replace(mountOptions, "addr="+source.Hostname(), "addr="+ip.String(), -1)
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.
Yeah, that's really an awesome advice.
Btw, currently the mountOptions is not configurable.
It is always nfsMountOpitons + ",addr=" + host.Host
, and the nfsMountOptions
is a hard-coded constant.
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.
Btw, currently the mountOptions is not configurable.
I see! That's good context to have. That certainly limits the scope of any issues here right now, but I think this change is still useful to make to avoid potential issues in the future.
I've created an issue #8357 aiming to expect test cases for this pr. |
94c5f45
to
21c1b96
Compare
7bc9bf6
to
2153a31
Compare
When docker using a nfs VolumeStore as a volume, the mount action will fail if the nfs-server url is a FQDN. A dotted ip url works well. When the linux syscall mount(source, target, flag, mountOptions) using for nfs mount, its mountOptions should contain 'addr=serverip' and the serverip must be an ip(ps. the url in source is useless). Thus the fix resolve the FQDN and give its mountOptions the 'addr=ip'. The mountOptions is generated as 'addr=host' at CreateMountSpec when creating the endpointVM. The fix choose to do the resolve just before the mounting action. Resolve: vmware#8043
2153a31
to
e912dce
Compare
e912dce
to
1d54af6
Compare
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.
Confirmed test functions as expected from CI https://ci-vic.vmware.com/vmware/vic/20465 logs.
When docker using a nfs VolumeStore as a volume, the mount action will fail if the nfs-server url is a FQDN. A dotted ip url works well. When the linux syscall mount(source, target, flag, mountOptions) using for nfs mount, its mountOptions should contain 'addr=serverip' and the serverip must be an ip(ps. the url in source is useless).
Thus the fix resolve the FQDN and replace mountOptions's 'addr=fqdn' to 'addr=ip'. The mountOptions is generated as 'addr=host' at CreateMountSpec when creating the endpointVM. But this fix choose to do the resolve just before the mounting action.
Fix #8043
Fix #8357
[specific ci=1-19-Docker-Volume-Create]