#26639: Local NFS volumes do not resolve hostnames#27329
#26639: Local NFS volumes do not resolve hostnames#27329justincormack merged 1 commit intomoby:masterfrom
Conversation
da8360c to
275f850
Compare
cpuguy83
left a comment
There was a problem hiding this comment.
The host lookup should be done before every mount() syscall rather than caching addresses.
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
No need for strings.Contains, a lookup to if addr := GetAddress(v.opts.MountOpts); addr != "" { ... } should suffice.
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
No need for IsIP. net.ResolveIPAddr will work just fine here if it is a hostname or an IP.
volume/local/local_unix.go
Outdated
volume/local/local_unix.go
Outdated
volume/local/local_unix.go
Outdated
|
08:35:30 These files are not properly gofmt'd: |
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
This would also match maddr= or something on some other mount type. Also we should probably just do this for nfs, as addr might mean something else on other mount types (there might be other network filesystems with a similar issue but these could be added).
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
This is not a helpful log message
volume/local/local_unix.go
Outdated
volume/local/local_unix.go
Outdated
volume/local/local_test.go
Outdated
There was a problem hiding this comment.
The opslist should already split on , so I don't see how this case could happen?
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
Looks like this can be removed instead of commented
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
You can do
if err != nil {
return errors.Wrapf(err, "unable to resolve hostname"
}So that you don't need an "else".
Perhaps include the actual hostname in the error message, as that may be valuable information
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
Do we need a regex here for MountType? Or simply v.opts.MountType == "nfs"
There was a problem hiding this comment.
Also, given that we'll still check if an addr is actually set below, checking addr= may not even be nescessary here (but open to suggestions)
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
Should we replace the value of v.opts.MountOps here, or should we use a copy, and leave the original options as-is? @cpuguy83 ?
|
Updated PR with changed.Can someone please review it ? |
|
@thaJeztah @cpuguy83 |
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
nit: to reduce code duplication, you could put opts1 := v.opts.MountOpts outside the if ... (at line 72), and always use the copy (opts1) at line 85
There was a problem hiding this comment.
Thanks @thaJeztah.
Removed duplication. Updated PR with same detail
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM, but left one suggestion
f14def9 to
522be5e
Compare
|
ping @justincormack PTAL |
|
@justincormack , Can you please take a look ? |
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
Should be compiled at the package level rather than on every mount call.
But do we really need to match the regex here vs just iterating the opts with getAddress?
In most cases the opts list should be small enough to not matter.
WDYT?
There was a problem hiding this comment.
Should also always check errors.
There was a problem hiding this comment.
Yes, I suggested doing that in #27329 (comment), perhaps we should skip the regex (since getAddress is checking for it anyway to verify it's not empty)
There was a problem hiding this comment.
Yes I think It can be in getAddress function ,Will remove it.
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
This wrap message is not really adding any context and just duplicating what is already there since the error from net will be lookup <addrValue>: no such host.
Maybe something like error resolving passed in nfs address.
Also, errors should always be started as lower case.
There was a problem hiding this comment.
changed error message
7fc7a31 to
18a2457
Compare
|
ping @cpuguy83 PTAL @dattatrayakumbhar04 can you squash your commits? |
3457450 to
20cd153
Compare
volume/local/local_test.go
Outdated
There was a problem hiding this comment.
getAddress is only defined for linux, but not for Windows.
Can probably move to a platform independent file.
20cd153 to
7d3acb5
Compare
|
@cpuguy83 @justincormack @thaJeztah |
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
should we replace, including the addr=? Is there a chance another option has the same string?
There was a problem hiding this comment.
e.g.
mountOpts = strings.Replace(mountOpts, "addr=" + addrValue, "addr=" + ipAddr.String(), 1)(maybe not needed, just wondering)
638c95e to
ce87725
Compare
|
@cpuguy83 @thaJeztah @justincormack |
volume/local/local.go
Outdated
There was a problem hiding this comment.
This needs to check for addr= at the start of the item.
volume/local/local_unix.go
Outdated
There was a problem hiding this comment.
please avoid unrelated whitespace changes
volume/local/local_unix.go
Outdated
95656ec to
1273d65
Compare
Signed-off-by: dattatrayakumbhar04 <dattatraya.kumbhar@gslab.com>
1273d65 to
668fa8a
Compare
|
LGTM from under the sea! |
fixes #26639
- What I did
Implemented code for mounting local NFS with hostname
Added method GetAddress, to get address/hostname from options. Added another Method IsIP, to verify if option has IP or Address. If option has hostname then used LookupHost built in function to convert to IPAddress.
- How to verify it
Note. Please make sure “nfs-server” is resolvable with Ip address.
- Description for the changelog
*- A picture of a cute animal *