Skip to content

Commit 62c5c63

Browse files
committed
Revert "Make external driver storage class name generation contain a more random suffix in case of double generation in the same framework context (twice in the same test)"
This reverts commit c50e7fd because it included API changes that shouldn't have been in that PR and fixing the storage class conflict inside the framework is probably the wrong place.
1 parent 086a86b commit 62c5c63

File tree

2 files changed

+21
-32
lines changed

2 files changed

+21
-32
lines changed

test/e2e/framework/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ go_library(
9292
"//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
9393
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
9494
"//staging/src/k8s.io/apiserver/pkg/authentication/serviceaccount:go_default_library",
95-
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
9695
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
9796
"//staging/src/k8s.io/client-go/discovery:go_default_library",
9897
"//staging/src/k8s.io/client-go/discovery/cached/memory:go_default_library",

test/e2e/framework/create.go

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/runtime"
3333
"k8s.io/apimachinery/pkg/runtime/schema"
34-
"k8s.io/apiserver/pkg/storage/names"
3534
"k8s.io/client-go/kubernetes/scheme"
3635
"k8s.io/client-go/tools/cache"
3736
"k8s.io/kubernetes/test/e2e/framework/testfiles"
@@ -101,9 +100,9 @@ func visitManifests(cb func([]byte) error, files ...string) error {
101100
return nil
102101
}
103102

104-
// PatchItems modifies the given items in place such that each
105-
// test gets its own instances, to avoid conflicts between different tests and
106-
// between tests and normal deployments.
103+
// PatchItems modifies the given items in place such that each test
104+
// gets its own instances, to avoid conflicts between different tests
105+
// and between tests and normal deployments.
107106
//
108107
// This is done by:
109108
// - creating namespaced items inside the test's namespace
@@ -288,27 +287,18 @@ var factories = map[What]ItemFactory{
288287
{"StorageClass"}: &storageClassFactory{},
289288
}
290289

291-
// uniquifyName makes the name of some item unique per namespace by appending the
292-
// generated unique name of the test namespace.
293-
func (f *Framework) uniquifyName(item *string) {
290+
// PatchName makes the name of some item unique by appending the
291+
// generated unique name.
292+
func (f *Framework) PatchName(item *string) {
294293
if *item != "" {
295294
*item = *item + "-" + f.UniqueName
296295
}
297296
}
298297

299-
// randomizeStorageClassName makes the name of the storage class unique per call
300-
// by appending the generated unique name of the test namespace and a random 5
301-
// character string
302-
func (f *Framework) randomizeStorageClassName(item *string) {
303-
if *item != "" {
304-
*item = names.SimpleNameGenerator.GenerateName(*item + "-" + f.UniqueName + "-")
305-
}
306-
}
307-
308-
// patchNamespace moves the item into the test's namespace. Not
298+
// PatchNamespace moves the item into the test's namespace. Not
309299
// all items can be namespaced. For those, the name also needs to be
310300
// patched.
311-
func (f *Framework) patchNamespace(item *string) {
301+
func (f *Framework) PatchNamespace(item *string) {
312302
if f.Namespace != nil {
313303
*item = f.Namespace.GetName()
314304
}
@@ -317,31 +307,31 @@ func (f *Framework) patchNamespace(item *string) {
317307
func (f *Framework) patchItemRecursively(item interface{}) error {
318308
switch item := item.(type) {
319309
case *rbac.Subject:
320-
f.patchNamespace(&item.Namespace)
310+
f.PatchNamespace(&item.Namespace)
321311
case *rbac.RoleRef:
322312
// TODO: avoid hard-coding this special name. Perhaps add a Framework.PredefinedRoles
323313
// which contains all role names that are defined cluster-wide before the test starts?
324314
// All those names are excempt from renaming. That list could be populated by querying
325315
// and get extended by tests.
326316
if item.Name != "e2e-test-privileged-psp" {
327-
f.uniquifyName(&item.Name)
317+
f.PatchName(&item.Name)
328318
}
329319
case *rbac.ClusterRole:
330-
f.uniquifyName(&item.Name)
320+
f.PatchName(&item.Name)
331321
case *rbac.Role:
332-
f.patchNamespace(&item.Namespace)
322+
f.PatchNamespace(&item.Namespace)
333323
// Roles are namespaced, but because for RoleRef above we don't
334324
// know whether the referenced role is a ClusterRole or Role
335325
// and therefore always renames, we have to do the same here.
336-
f.uniquifyName(&item.Name)
326+
f.PatchName(&item.Name)
337327
case *storage.StorageClass:
338-
f.randomizeStorageClassName(&item.Name)
328+
f.PatchName(&item.Name)
339329
case *v1.ServiceAccount:
340-
f.patchNamespace(&item.ObjectMeta.Namespace)
330+
f.PatchNamespace(&item.ObjectMeta.Namespace)
341331
case *v1.Secret:
342-
f.patchNamespace(&item.ObjectMeta.Namespace)
332+
f.PatchNamespace(&item.ObjectMeta.Namespace)
343333
case *rbac.ClusterRoleBinding:
344-
f.uniquifyName(&item.Name)
334+
f.PatchName(&item.Name)
345335
for i := range item.Subjects {
346336
if err := f.patchItemRecursively(&item.Subjects[i]); err != nil {
347337
return errors.Wrapf(err, "%T", f)
@@ -351,7 +341,7 @@ func (f *Framework) patchItemRecursively(item interface{}) error {
351341
return errors.Wrapf(err, "%T", f)
352342
}
353343
case *rbac.RoleBinding:
354-
f.patchNamespace(&item.Namespace)
344+
f.PatchNamespace(&item.Namespace)
355345
for i := range item.Subjects {
356346
if err := f.patchItemRecursively(&item.Subjects[i]); err != nil {
357347
return errors.Wrapf(err, "%T", f)
@@ -361,11 +351,11 @@ func (f *Framework) patchItemRecursively(item interface{}) error {
361351
return errors.Wrapf(err, "%T", f)
362352
}
363353
case *v1.Service:
364-
f.patchNamespace(&item.ObjectMeta.Namespace)
354+
f.PatchNamespace(&item.ObjectMeta.Namespace)
365355
case *apps.StatefulSet:
366-
f.patchNamespace(&item.ObjectMeta.Namespace)
356+
f.PatchNamespace(&item.ObjectMeta.Namespace)
367357
case *apps.DaemonSet:
368-
f.patchNamespace(&item.ObjectMeta.Namespace)
358+
f.PatchNamespace(&item.ObjectMeta.Namespace)
369359
default:
370360
return errors.Errorf("missing support for patching item of type %T", item)
371361
}

0 commit comments

Comments
 (0)