-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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 mounting NFS resources in IPv6 bare-metal environment #101066 #101067
Fix mounting NFS resources in IPv6 bare-metal environment #101066 #101067
Conversation
@Elbehery: The label(s) `/label nfs
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@Elbehery: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Welcome @Elbehery! |
Hi @Elbehery. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
In addition to the testing procedure described in the
|
/ok-to-test |
@jsafrane added a test case with literal built a new binary, tested upon |
pkg/volume/nfs/nfs_test.go
Outdated
Name: "vol1", | ||
VolumeSource: v1.VolumeSource{NFS: &v1.NFSVolumeSource{Server: "0:0:0:0:0:0:0:1", Path: "/somepath", ReadOnly: false}}, | ||
} | ||
doTestPlugin(t, volume.NewSpecFromVolume(vol)) |
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.
doTestPlugin does not test that the plugin added [ ]
around the IP address, you need to add it there.
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.
@jsafrane nfsMounter
does not expose server
field, so that I can assert upon it.
I have been trying to find an interface implemented by nfsMounter
that exposes the field, but I could not. I can :-
func (nfsMounter *nfsMounter) getServer() string {
return nfsMounter.server
}
What do u think ?
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 meant something like this:
--- a/pkg/volume/nfs/nfs_test.go
+++ b/pkg/volume/nfs/nfs_test.go
@@ -96,7 +96,7 @@ func TestRecycler(t *testing.T) {
}
}
-func doTestPlugin(t *testing.T, spec *volume.Spec) {
+func doTestPlugin(t *testing.T, spec *volume.Spec, expectedDevice string) {
tmpDir, err := utiltesting.MkTmpdir("nfs_test")
if err != nil {
t.Fatalf("error creating temp dir: %v", err)
@@ -146,9 +146,6 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if mntDevs[0].Type != "nfs" {
t.Errorf("unexpected type of mounted devices. expected: %v, got %v", "nfs", mntDevs[0].Type)
}
- src, _, _ := getVolumeSource(spec)
- srvr := getServerFromSource(src)
- expectedDevice := fmt.Sprintf("%s:%s", srvr, src.Path)
if mntDevs[0].Device != expectedDevice {
t.Errorf("unexpected nfs device, expected %q, got: %q", expectedDevice, mntDevs[0].Device)
}
@@ -203,7 +200,7 @@ func TestIPV6VolumeSource(t *testing.T) {
Name: "vol1",
VolumeSource: v1.VolumeSource{NFS: &v1.NFSVolumeSource{Server: "0:0:0:0:0:0:0:1", Path: "/somepath", ReadOnly: false}},
}
- doTestPlugin(t, volume.NewSpecFromVolume(vol))
+ doTestPlugin(t, volume.NewSpecFromVolume(vol), "[0:0:0:0:0:0:0:1]:/somepath")
}
func TestIPV4VolumeSource(t *testing.T) {
(+ you need to update all other doTestPlugin
calls)
This way you can explicitly specify that []
should be added to IPv6 addresses and not to ipv4.
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.
@jsafrane added in the last commit 👍🏽
7858607
to
045fdaf
Compare
pkg/volume/nfs/nfs_test.go
Outdated
@@ -118,6 +119,18 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) { | |||
if mounter == nil { | |||
t.Errorf("Got a nil Mounter") | |||
} | |||
if nfsm, ok := mounter.(*nfsMounter); ok { |
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.
@jsafrane I avoided changing anything in the pkg
itself for testing, so i came up with this way, I hope it suffice
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.
@aojea do you have a comment on this mock
? .. I tried to avoid adding a method
just to assert un-exported
field
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.
well, to be honest, the test has exactly the same code that the functionality, the only way to fail is if one of those diverge in the future :)
just throwing an idea, what if the fix goes here
kubernetes/pkg/volume/nfs/nfs.go
Line 258 in 4f6c595
source := fmt.Sprintf("%s:%s", nfsMounter.server, nfsMounter.exportPath) |
it seems a better place that current one , if IPv6 you build the source
with brackets for the server.
This way, you can mock nfsMounter.mounter.MountSensitiveWithoutSystemd(
kubernetes/pkg/volume/nfs/nfs.go
Line 191 in 4f6c595
mounter mount.Interface |
and assert the server ip in mountOptions
kubernetes/pkg/volume/nfs/nfs.go
Line 264 in 4f6c595
err = nfsMounter.mounter.MountSensitiveWithoutSystemd(source, dir, "nfs", mountOptions, 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.
@aojea this way, the fix will affect only the mounter
when it is being setUp
not created
.
The problem arose in the first place, when pods
consuming nfs
could not find the resource, and
I searched the usage of both setUp
which affects the mounter only when used. On the other hand, newMounter
is used by kubelet
so when the resource is actually allocated.
Please correct me if I am wrong 🙏🏽
045fdaf
to
43959da
Compare
4e48c00
to
859fe68
Compare
/lgtm |
/retest |
/retest Review the full test history for this PR. Silence the bot with an |
15 similar comments
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
What type of PR is this?
/kind bug
/kind storage
/label nfs
/label ipv6
What this PR does / why we need it:
Fix mounting
nfs
volumes inipv6
environment.Which issue(s) this PR fixes:
Fixes #101066
Special notes for your reviewer:
Enclose only ipv6 within
[ ]
.