Skip to content

Commit

Permalink
Merge pull request #75792 from verult/automated-cherry-pick-of-#75746…
Browse files Browse the repository at this point in the history
…-upstream-release-1.13

Automated cherry pick of #75746: Updated regional PD minimum size; changed regional PD
  • Loading branch information
k8s-ci-robot committed Apr 6, 2019
2 parents 1a85126 + a2052f4 commit e7b7983
Showing 1 changed file with 17 additions and 40 deletions.
57 changes: 17 additions & 40 deletions test/e2e/storage/regional_pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
storage "k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
Expand All @@ -52,6 +51,7 @@ const (
statefulSetReadyTimeout = 3 * time.Minute
taintKeyPrefix = "zoneTaint_"
repdMinSize = "200Gi"
pvcName = "regional-pd-vol"
)

var _ = utils.SIGDescribe("Regional PD", func() {
Expand Down Expand Up @@ -153,8 +153,21 @@ func testVolumeProvisioning(c clientset.Interface, ns string) {

func testZonalFailover(c clientset.Interface, ns string) {
cloudZones := getTwoRandomZones(c)
class := newRegionalStorageClass(ns, cloudZones)
claimTemplate := newClaimTemplate(ns)
testSpec := testsuites.StorageClassTest{
Name: "Regional PD Failover on GCE/GKE",
CloudProviders: []string{"gce", "gke"},
Provisioner: "kubernetes.io/gce-pd",
Parameters: map[string]string{
"type": "pd-standard",
"zones": strings.Join(cloudZones, ","),
"replication-type": "regional-pd",
},
ClaimSize: repdMinSize,
ExpectedSize: repdMinSize,
}
class := newStorageClass(testSpec, ns, "" /* suffix */)
claimTemplate := newClaim(testSpec, ns, "" /* suffix */)
claimTemplate.Name = pvcName
claimTemplate.Spec.StorageClassName = &class.Name
statefulSet, service, regionalPDLabels := newStatefulSet(claimTemplate, ns)

Expand Down Expand Up @@ -503,7 +516,7 @@ func newPodTemplate(labels map[string]string) *v1.PodTemplateSpec {
Name: "web",
}},
VolumeMounts: []v1.VolumeMount{{
Name: "regional-pd-vol",
Name: pvcName,
MountPath: "/mnt/data/regional-pd",
}},
},
Expand All @@ -512,42 +525,6 @@ func newPodTemplate(labels map[string]string) *v1.PodTemplateSpec {
}
}

func newClaimTemplate(ns string) *v1.PersistentVolumeClaim {
return &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: "regional-pd-vol",
Namespace: ns,
},
Spec: v1.PersistentVolumeClaimSpec{
AccessModes: []v1.PersistentVolumeAccessMode{
v1.ReadWriteOnce,
},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): resource.MustParse("1Gi"),
},
},
},
}
}

func newRegionalStorageClass(namespace string, zones []string) *storage.StorageClass {
return &storage.StorageClass{
TypeMeta: metav1.TypeMeta{
Kind: "StorageClass",
},
ObjectMeta: metav1.ObjectMeta{
Name: namespace + "-sc",
},
Provisioner: "kubernetes.io/gce-pd",
Parameters: map[string]string{
"type": "pd-standard",
"zones": strings.Join(zones, ","),
"replication-type": "regional-pd",
},
}
}

func getTwoRandomZones(c clientset.Interface) []string {
zones, err := framework.GetClusterZones(c)
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit e7b7983

Please sign in to comment.