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

Fix mounting NFS resources in IPv6 bare-metal environment #101066 #101067

Conversation

Elbehery
Copy link
Contributor

@Elbehery Elbehery commented Apr 13, 2021

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 in ipv6 environment.

Which issue(s) this PR fixes:

Fixes #101066

Special notes for your reviewer:

Enclose only ipv6 within [ ].

Fixed mounting of NFS volumes when IPv6 address is used as a server.

@k8s-ci-robot
Copy link
Contributor

@Elbehery: The label(s) `/label nfs
, /label ipv6

cannot be applied. These labels are supported:api-review, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, team/katacoda`

In response to this:

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 in ipv6 environment.

Which issue(s) this PR fixes:

Fixes #101066

Special notes for your reviewer:

Enclose only ipv6 within [ ].

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.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 13, 2021
@k8s-ci-robot
Copy link
Contributor

@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 triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 13, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @Elbehery!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 13, 2021
@k8s-ci-robot k8s-ci-robot requested review from msau42 and saad-ali April 13, 2021 12:11
@Elbehery
Copy link
Contributor Author

In addition to the testing procedure described in the contribute docs, I have tested it locally according to the reproducing steps described in #101066, below are the logs :-

$kubectl get svc                
NAME         TYPE        CLUSTER-IP         EXTERNAL-IP   PORT(S)                      AGE
kubernetes   ClusterIP   fd00:10:96::1      <none>        443/TCP                      3h35m
nfs-server   ClusterIP   fd00:10:96::63f1   <none>        2049/TCP,20048/TCP,111/TCP   89s
$kubectl get pod -w                   
NAME                READY   STATUS              RESTARTS   AGE
nfs-busybox-ppv7h   0/1     ContainerCreating   0          2s
nfs-busybox-xqrqp   0/1     ContainerCreating   0          2s
nfs-server-x86wb    1/1     Running             0          2m34s
nfs-busybox-ppv7h   1/1     Running             0          7s
nfs-busybox-xqrqp   1/1     Running             0          8s

@jsafrane
Copy link
Member

/ok-to-test
/sig storage

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 13, 2021
@Elbehery
Copy link
Contributor Author

@jsafrane added a test case with literal ipv4

built a new binary, tested upon ipv4, ipv6, and dualcluster configurations, all containersrunningandnfs` volumes mounted

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))
Copy link
Member

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.

Copy link
Contributor Author

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 ?

Copy link
Member

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.

Copy link
Contributor Author

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 👍🏽

@Elbehery Elbehery force-pushed the fix-nfs-storage-ipv6_add_square_brackets branch 2 times, most recently from 7858607 to 045fdaf Compare April 13, 2021 19:00
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 13, 2021
@@ -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 {
Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Member

@aojea aojea Apr 13, 2021

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

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(

mounter mount.Interface

and assert the server ip in mountOptions

err = nfsMounter.mounter.MountSensitiveWithoutSystemd(source, dir, "nfs", mountOptions, nil)

Copy link
Contributor Author

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 🙏🏽

@Elbehery Elbehery force-pushed the fix-nfs-storage-ipv6_add_square_brackets branch from 045fdaf to 43959da Compare April 13, 2021 20:08
@Elbehery Elbehery force-pushed the fix-nfs-storage-ipv6_add_square_brackets branch from 4e48c00 to 859fe68 Compare April 28, 2021 15:25
@jsafrane
Copy link
Member

/lgtm
/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 29, 2021
@Elbehery
Copy link
Contributor Author

/retest

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

15 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sig-storage] [Driver: nfs] bare-metal IPv6 environment, pods fail to mount nfs storage resources
6 participants