mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	Merge pull request #90689 from aojea/nfsv6
add ipv6 support to the e2e nfs tests
This commit is contained in:
		@@ -78,14 +78,14 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() {
 | 
				
			|||||||
	////////////////////////////////////////////////////////////////////////
 | 
						////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
	ginkgo.Describe("NFSv4", func() {
 | 
						ginkgo.Describe("NFSv4", func() {
 | 
				
			||||||
		ginkgo.It("should be mountable for NFSv4", func() {
 | 
							ginkgo.It("should be mountable for NFSv4", func() {
 | 
				
			||||||
			config, _, serverIP := e2evolume.NewNFSServer(c, namespace.Name, []string{})
 | 
								config, _, serverHost := e2evolume.NewNFSServer(c, namespace.Name, []string{})
 | 
				
			||||||
			defer e2evolume.TestServerCleanup(f, config)
 | 
								defer e2evolume.TestServerCleanup(f, config)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			tests := []e2evolume.Test{
 | 
								tests := []e2evolume.Test{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					Volume: v1.VolumeSource{
 | 
										Volume: v1.VolumeSource{
 | 
				
			||||||
						NFS: &v1.NFSVolumeSource{
 | 
											NFS: &v1.NFSVolumeSource{
 | 
				
			||||||
							Server:   serverIP,
 | 
												Server:   serverHost,
 | 
				
			||||||
							Path:     "/",
 | 
												Path:     "/",
 | 
				
			||||||
							ReadOnly: true,
 | 
												ReadOnly: true,
 | 
				
			||||||
						},
 | 
											},
 | 
				
			||||||
@@ -102,14 +102,14 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ginkgo.Describe("NFSv3", func() {
 | 
						ginkgo.Describe("NFSv3", func() {
 | 
				
			||||||
		ginkgo.It("should be mountable for NFSv3", func() {
 | 
							ginkgo.It("should be mountable for NFSv3", func() {
 | 
				
			||||||
			config, _, serverIP := e2evolume.NewNFSServer(c, namespace.Name, []string{})
 | 
								config, _, serverHost := e2evolume.NewNFSServer(c, namespace.Name, []string{})
 | 
				
			||||||
			defer e2evolume.TestServerCleanup(f, config)
 | 
								defer e2evolume.TestServerCleanup(f, config)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			tests := []e2evolume.Test{
 | 
								tests := []e2evolume.Test{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					Volume: v1.VolumeSource{
 | 
										Volume: v1.VolumeSource{
 | 
				
			||||||
						NFS: &v1.NFSVolumeSource{
 | 
											NFS: &v1.NFSVolumeSource{
 | 
				
			||||||
							Server:   serverIP,
 | 
												Server:   serverHost,
 | 
				
			||||||
							Path:     "/exports",
 | 
												Path:     "/exports",
 | 
				
			||||||
							ReadOnly: true,
 | 
												ReadOnly: true,
 | 
				
			||||||
						},
 | 
											},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,6 +44,7 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	v1 "k8s.io/api/core/v1"
 | 
						v1 "k8s.io/api/core/v1"
 | 
				
			||||||
@@ -143,7 +144,7 @@ type Test struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewNFSServer is a NFS-specific wrapper for CreateStorageServer.
 | 
					// NewNFSServer is a NFS-specific wrapper for CreateStorageServer.
 | 
				
			||||||
func NewNFSServer(cs clientset.Interface, namespace string, args []string) (config TestConfig, pod *v1.Pod, ip string) {
 | 
					func NewNFSServer(cs clientset.Interface, namespace string, args []string) (config TestConfig, pod *v1.Pod, host string) {
 | 
				
			||||||
	config = TestConfig{
 | 
						config = TestConfig{
 | 
				
			||||||
		Namespace:          namespace,
 | 
							Namespace:          namespace,
 | 
				
			||||||
		Prefix:             "nfs",
 | 
							Prefix:             "nfs",
 | 
				
			||||||
@@ -155,8 +156,11 @@ func NewNFSServer(cs clientset.Interface, namespace string, args []string) (conf
 | 
				
			|||||||
	if len(args) > 0 {
 | 
						if len(args) > 0 {
 | 
				
			||||||
		config.ServerArgs = args
 | 
							config.ServerArgs = args
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pod, ip = CreateStorageServer(cs, config)
 | 
						pod, host = CreateStorageServer(cs, config)
 | 
				
			||||||
	return config, pod, ip
 | 
						if strings.Contains(host, ":") {
 | 
				
			||||||
 | 
							host = "[" + host + "]"
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return config, pod, host
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewGlusterfsServer is a GlusterFS-specific wrapper for CreateStorageServer. Also creates the gluster endpoints object.
 | 
					// NewGlusterfsServer is a GlusterFS-specific wrapper for CreateStorageServer. Also creates the gluster endpoints object.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,7 +81,7 @@ type nfsDriver struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type nfsVolume struct {
 | 
					type nfsVolume struct {
 | 
				
			||||||
	serverIP  string
 | 
						serverHost string
 | 
				
			||||||
	serverPod  *v1.Pod
 | 
						serverPod  *v1.Pod
 | 
				
			||||||
	f          *framework.Framework
 | 
						f          *framework.Framework
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -129,7 +129,7 @@ func (n *nfsDriver) GetVolumeSource(readOnly bool, fsType string, e2evolume test
 | 
				
			|||||||
	framework.ExpectEqual(ok, true, "Failed to cast test volume to NFS test volume")
 | 
						framework.ExpectEqual(ok, true, "Failed to cast test volume to NFS test volume")
 | 
				
			||||||
	return &v1.VolumeSource{
 | 
						return &v1.VolumeSource{
 | 
				
			||||||
		NFS: &v1.NFSVolumeSource{
 | 
							NFS: &v1.NFSVolumeSource{
 | 
				
			||||||
			Server:   nv.serverIP,
 | 
								Server:   nv.serverHost,
 | 
				
			||||||
			Path:     "/",
 | 
								Path:     "/",
 | 
				
			||||||
			ReadOnly: readOnly,
 | 
								ReadOnly: readOnly,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -141,7 +141,7 @@ func (n *nfsDriver) GetPersistentVolumeSource(readOnly bool, fsType string, e2ev
 | 
				
			|||||||
	framework.ExpectEqual(ok, true, "Failed to cast test volume to NFS test volume")
 | 
						framework.ExpectEqual(ok, true, "Failed to cast test volume to NFS test volume")
 | 
				
			||||||
	return &v1.PersistentVolumeSource{
 | 
						return &v1.PersistentVolumeSource{
 | 
				
			||||||
		NFS: &v1.NFSVolumeSource{
 | 
							NFS: &v1.NFSVolumeSource{
 | 
				
			||||||
			Server:   nv.serverIP,
 | 
								Server:   nv.serverHost,
 | 
				
			||||||
			Path:     "/",
 | 
								Path:     "/",
 | 
				
			||||||
			ReadOnly: readOnly,
 | 
								ReadOnly: readOnly,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -199,10 +199,10 @@ func (n *nfsDriver) CreateVolume(config *testsuites.PerTestConfig, volType testp
 | 
				
			|||||||
	case testpatterns.InlineVolume:
 | 
						case testpatterns.InlineVolume:
 | 
				
			||||||
		fallthrough
 | 
							fallthrough
 | 
				
			||||||
	case testpatterns.PreprovisionedPV:
 | 
						case testpatterns.PreprovisionedPV:
 | 
				
			||||||
		c, serverPod, serverIP := e2evolume.NewNFSServer(cs, ns.Name, []string{})
 | 
							c, serverPod, serverHost := e2evolume.NewNFSServer(cs, ns.Name, []string{})
 | 
				
			||||||
		config.ServerConfig = &c
 | 
							config.ServerConfig = &c
 | 
				
			||||||
		return &nfsVolume{
 | 
							return &nfsVolume{
 | 
				
			||||||
			serverIP:  serverIP,
 | 
								serverHost: serverHost,
 | 
				
			||||||
			serverPod:  serverPod,
 | 
								serverPod:  serverPod,
 | 
				
			||||||
			f:          f,
 | 
								f:          f,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,7 +83,7 @@ var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
 | 
				
			|||||||
		nfsServerPod                *v1.Pod
 | 
							nfsServerPod                *v1.Pod
 | 
				
			||||||
		nfsPVconfig                 e2epv.PersistentVolumeConfig
 | 
							nfsPVconfig                 e2epv.PersistentVolumeConfig
 | 
				
			||||||
		pvcConfig                   e2epv.PersistentVolumeClaimConfig
 | 
							pvcConfig                   e2epv.PersistentVolumeClaimConfig
 | 
				
			||||||
		nfsServerIP, clientNodeIP string
 | 
							nfsServerHost, clientNodeIP string
 | 
				
			||||||
		clientNode                  *v1.Node
 | 
							clientNode                  *v1.Node
 | 
				
			||||||
		volLabel                    labels.Set
 | 
							volLabel                    labels.Set
 | 
				
			||||||
		selector                    *metav1.LabelSelector
 | 
							selector                    *metav1.LabelSelector
 | 
				
			||||||
@@ -99,13 +99,13 @@ var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
 | 
				
			|||||||
		volLabel = labels.Set{e2epv.VolumeSelectorKey: ns}
 | 
							volLabel = labels.Set{e2epv.VolumeSelectorKey: ns}
 | 
				
			||||||
		selector = metav1.SetAsLabelSelector(volLabel)
 | 
							selector = metav1.SetAsLabelSelector(volLabel)
 | 
				
			||||||
		// Start the NFS server pod.
 | 
							// Start the NFS server pod.
 | 
				
			||||||
		_, nfsServerPod, nfsServerIP = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"})
 | 
							_, nfsServerPod, nfsServerHost = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"})
 | 
				
			||||||
		nfsPVconfig = e2epv.PersistentVolumeConfig{
 | 
							nfsPVconfig = e2epv.PersistentVolumeConfig{
 | 
				
			||||||
			NamePrefix: "nfs-",
 | 
								NamePrefix: "nfs-",
 | 
				
			||||||
			Labels:     volLabel,
 | 
								Labels:     volLabel,
 | 
				
			||||||
			PVSource: v1.PersistentVolumeSource{
 | 
								PVSource: v1.PersistentVolumeSource{
 | 
				
			||||||
				NFS: &v1.NFSVolumeSource{
 | 
									NFS: &v1.NFSVolumeSource{
 | 
				
			||||||
					Server:   nfsServerIP,
 | 
										Server:   nfsServerHost,
 | 
				
			||||||
					Path:     "/exports",
 | 
										Path:     "/exports",
 | 
				
			||||||
					ReadOnly: false,
 | 
										ReadOnly: false,
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -123,17 +123,17 @@ var _ = utils.SIGDescribe("PersistentVolumes", func() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		var (
 | 
							var (
 | 
				
			||||||
			nfsServerPod *v1.Pod
 | 
								nfsServerPod *v1.Pod
 | 
				
			||||||
			serverIP     string
 | 
								serverHost   string
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ginkgo.BeforeEach(func() {
 | 
							ginkgo.BeforeEach(func() {
 | 
				
			||||||
			_, nfsServerPod, serverIP = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"})
 | 
								_, nfsServerPod, serverHost = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"})
 | 
				
			||||||
			pvConfig = e2epv.PersistentVolumeConfig{
 | 
								pvConfig = e2epv.PersistentVolumeConfig{
 | 
				
			||||||
				NamePrefix: "nfs-",
 | 
									NamePrefix: "nfs-",
 | 
				
			||||||
				Labels:     volLabel,
 | 
									Labels:     volLabel,
 | 
				
			||||||
				PVSource: v1.PersistentVolumeSource{
 | 
									PVSource: v1.PersistentVolumeSource{
 | 
				
			||||||
					NFS: &v1.NFSVolumeSource{
 | 
										NFS: &v1.NFSVolumeSource{
 | 
				
			||||||
						Server:   serverIP,
 | 
											Server:   serverHost,
 | 
				
			||||||
						Path:     "/exports",
 | 
											Path:     "/exports",
 | 
				
			||||||
						ReadOnly: false,
 | 
											ReadOnly: false,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user