From ebcc558734d92f85c9d50095b83474cb42439141 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Fri, 7 Aug 2015 10:24:29 +0200 Subject: [PATCH] Revert "Use a service between e2e volume tests clients and servers." iSCSI and RBD volumes don't work as Kubernetes services - these protocols are broken by S-NAT created by kube-proxy - at least iSCSI exhanges real IP address of the iSCSI target as part of the protocol. This reverts commit 118004c16656617295234bc250da11788dec62c2. --- .../for-tests/volumes-tester/nfs/run_nfs.sh | 4 +- test/e2e/persistent_volumes.go | 3 +- test/e2e/volumes.go | 83 +++++++++++-------- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/contrib/for-tests/volumes-tester/nfs/run_nfs.sh b/contrib/for-tests/volumes-tester/nfs/run_nfs.sh index c22eeb0cdf6..5468c1d7c98 100755 --- a/contrib/for-tests/volumes-tester/nfs/run_nfs.sh +++ b/contrib/for-tests/volumes-tester/nfs/run_nfs.sh @@ -20,9 +20,7 @@ function start() # prepare /etc/exports for i in "$@"; do # fsid=0: needed for NFSv4 - # no_root_squash: root can read/write - # insecure: allow access from ports > 1024 - echo "$i *(rw,fsid=0,no_root_squash,insecure)" >> /etc/exports + echo "$i *(rw,fsid=0,no_root_squash)" >> /etc/exports echo "Serving $i" done diff --git a/test/e2e/persistent_volumes.go b/test/e2e/persistent_volumes.go index 4514669f458..6b19705c437 100644 --- a/test/e2e/persistent_volumes.go +++ b/test/e2e/persistent_volumes.go @@ -63,7 +63,8 @@ var _ = Describe("[Skipped] persistentVolumes", func() { volumeTestCleanup(c, config) }() - serverIP := startVolumeServer(c, config) + pod := startVolumeServer(c, config) + serverIP := pod.Status.PodIP Logf("NFS server IP address: %v", serverIP) pv := makePersistentVolume(serverIP) diff --git a/test/e2e/volumes.go b/test/e2e/volumes.go index 1f75877a2e0..3e567b0ce72 100644 --- a/test/e2e/volumes.go +++ b/test/e2e/volumes.go @@ -35,7 +35,6 @@ import ( "fmt" "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client" - "k8s.io/kubernetes/pkg/util" "time" . "github.com/onsi/ginkgo" @@ -56,15 +55,13 @@ type VolumeTestConfig struct { } // Starts a container specified by config.serverImage and exports all -// config.serverPorts from it via a service. The function returns IP -// address of the service. -func startVolumeServer(client *client.Client, config VolumeTestConfig) string { +// config.serverPorts from it. The returned pod should be used to get the server +// IP address and create appropriate VolumeSource. +func startVolumeServer(client *client.Client, config VolumeTestConfig) *api.Pod { podClient := client.Pods(config.namespace) - serviceClient := client.Services(config.namespace) portCount := len(config.serverPorts) serverPodPorts := make([]api.ContainerPort, portCount) - servicePorts := make([]api.ServicePort, portCount) for i := 0; i < portCount; i++ { portName := fmt.Sprintf("%s-%d", config.prefix, i) @@ -74,12 +71,6 @@ func startVolumeServer(client *client.Client, config VolumeTestConfig) string { ContainerPort: config.serverPorts[i], Protocol: api.ProtocolTCP, } - servicePorts[i] = api.ServicePort{ - Name: portName, - Protocol: "TCP", - Port: config.serverPorts[i], - TargetPort: util.NewIntOrStringFromInt(config.serverPorts[i]), - } } By(fmt.Sprint("creating ", config.prefix, " server pod")) @@ -115,26 +106,13 @@ func startVolumeServer(client *client.Client, config VolumeTestConfig) string { expectNoError(waitForPodRunningInNamespace(client, serverPod.Name, config.namespace)) - By(fmt.Sprint("creating ", config.prefix, " service")) - service := &api.Service{ - ObjectMeta: api.ObjectMeta{ - Name: config.prefix + "-server", - }, - Spec: api.ServiceSpec{ - Selector: map[string]string{ - "role": config.prefix + "-server", - }, - Ports: servicePorts, - }, - } - createdService, err := serviceClient.Create(service) - expectNoError(err, "Failed to create %s service: %v", service.Name, err) + By("locating the server pod") + pod, err := podClient.Get(serverPod.Name) + expectNoError(err, "Cannot locate the server pod %v: %v", serverPod.Name, err) By("sleeping a bit to give the server time to start") time.Sleep(20 * time.Second) - - ip := createdService.Spec.ClusterIP - return ip + return pod } // Clean both server and client pods. @@ -144,11 +122,9 @@ func volumeTestCleanup(client *client.Client, config VolumeTestConfig) { defer GinkgoRecover() podClient := client.Pods(config.namespace) - serviceClient := client.Services(config.namespace) // ignore all errors, the pods may not be even created podClient.Delete(config.prefix+"-client", nil) - serviceClient.Delete(config.prefix + "-server") podClient.Delete(config.prefix+"-server", nil) } @@ -261,7 +237,8 @@ var _ = Describe("Volumes", func() { volumeTestCleanup(c, config) } }() - serverIP := startVolumeServer(c, config) + pod := startVolumeServer(c, config) + serverIP := pod.Status.PodIP Logf("NFS server IP address: %v", serverIP) volume := api.VolumeSource{ @@ -297,9 +274,49 @@ var _ = Describe("Volumes", func() { volumeTestCleanup(c, config) } }() - serverIP := startVolumeServer(c, config) + pod := startVolumeServer(c, config) + serverIP := pod.Status.PodIP Logf("Gluster server IP address: %v", serverIP) + // create Endpoints for the server + endpoints := api.Endpoints{ + TypeMeta: api.TypeMeta{ + Kind: "Endpoints", + APIVersion: "v1", + }, + ObjectMeta: api.ObjectMeta{ + Name: config.prefix + "-server", + }, + Subsets: []api.EndpointSubset{ + { + Addresses: []api.EndpointAddress{ + { + IP: serverIP, + }, + }, + Ports: []api.EndpointPort{ + { + Name: "gluster", + Port: 24007, + Protocol: api.ProtocolTCP, + }, + }, + }, + }, + } + + endClient := c.Endpoints(config.namespace) + + defer func() { + if clean { + endClient.Delete(config.prefix + "-server") + } + }() + + if _, err := endClient.Create(&endpoints); err != nil { + Failf("Failed to create endpoints for Gluster server: %v", err) + } + volume := api.VolumeSource{ Glusterfs: &api.GlusterfsVolumeSource{ EndpointsName: config.prefix + "-server",