Skip to content

Commit 9c92b37

Browse files
committed
remove clusterName from VolumeOptions
1 parent 9d87fa2 commit 9c92b37

File tree

8 files changed

+0
-50
lines changed

8 files changed

+0
-50
lines changed

cmd/kube-controller-manager/app/core.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ func startPersistentVolumeBinderController(ctx context.Context, controllerContex
337337
KubeClient: controllerContext.ClientBuilder.ClientOrDie("persistent-volume-binder"),
338338
SyncPeriod: controllerContext.ComponentConfig.PersistentVolumeBinderController.PVClaimBinderSyncPeriod.Duration,
339339
VolumePlugins: plugins,
340-
ClusterName: controllerContext.ComponentConfig.KubeCloudShared.ClusterName,
341340
VolumeInformer: controllerContext.InformerFactory.Core().V1().PersistentVolumes(),
342341
ClaimInformer: controllerContext.InformerFactory.Core().V1().PersistentVolumeClaims(),
343342
ClassInformer: controllerContext.InformerFactory.Storage().V1().StorageClasses(),

pkg/controller/volume/persistentvolume/pv_controller.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ type PersistentVolumeController struct {
156156
eventRecorder record.EventRecorder
157157
volumePluginMgr vol.VolumePluginMgr
158158
enableDynamicProvisioning bool
159-
clusterName string
160159
resyncPeriod time.Duration
161160

162161
// Cache of the last known version of volumes and claims. This cache is
@@ -1642,7 +1641,6 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(
16421641
options := vol.VolumeOptions{
16431642
PersistentVolumeReclaimPolicy: *storageClass.ReclaimPolicy,
16441643
MountOptions: storageClass.MountOptions,
1645-
ClusterName: ctrl.clusterName,
16461644
PVName: pvName,
16471645
PVC: claim,
16481646
Parameters: storageClass.Parameters,

pkg/controller/volume/persistentvolume/pv_controller_base.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type ControllerParameters struct {
6464
KubeClient clientset.Interface
6565
SyncPeriod time.Duration
6666
VolumePlugins []vol.VolumePlugin
67-
ClusterName string
6867
VolumeInformer coreinformers.PersistentVolumeInformer
6968
ClaimInformer coreinformers.PersistentVolumeClaimInformer
7069
ClassInformer storageinformers.StorageClassInformer
@@ -86,7 +85,6 @@ func NewController(ctx context.Context, p ControllerParameters) (*PersistentVolu
8685
eventRecorder: eventRecorder,
8786
runningOperations: goroutinemap.NewGoRoutineMap(true /* exponentialBackOffOnError */),
8887
enableDynamicProvisioning: p.EnableDynamicProvisioning,
89-
clusterName: p.ClusterName,
9088
createProvisionedPVRetryCount: createProvisionedPVRetryCount,
9189
createProvisionedPVInterval: createProvisionedPVInterval,
9290
claimQueue: workqueue.NewTypedWithConfig(workqueue.TypedQueueConfig[string]{Name: "claims"}),

pkg/volume/plugins.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ type VolumeOptions struct {
8282
// i.e. with required capacity, accessMode, labels matching PVC.Selector and
8383
// so on.
8484
PVC *v1.PersistentVolumeClaim
85-
// Unique name of Kubernetes cluster.
86-
ClusterName string
8785
// Volume provisioning parameters from StorageClass
8886
Parameters map[string]string
8987
}

pkg/volume/util/util.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,22 +200,6 @@ func CalculateTimeoutForVolume(minimumTimeout, timeoutIncrement int, pv *v1.Pers
200200
return timeout
201201
}
202202

203-
// GenerateVolumeName returns a PV name with clusterName prefix. The function
204-
// should be used to generate a name of GCE PD or Cinder volume. It basically
205-
// adds "<clusterName>-dynamic-" before the PV name, making sure the resulting
206-
// string fits given length and cuts "dynamic" if not.
207-
func GenerateVolumeName(clusterName, pvName string, maxLength int) string {
208-
prefix := clusterName + "-dynamic"
209-
pvLen := len(pvName)
210-
211-
// cut the "<clusterName>-dynamic" to fit full pvName into maxLength
212-
// +1 for the '-' dash
213-
if pvLen+1+len(prefix) > maxLength {
214-
prefix = prefix[:maxLength-pvLen-1]
215-
}
216-
return prefix + "-" + pvName
217-
}
218-
219203
// GetPath checks if the path from the mounter is empty.
220204
func GetPath(mounter volume.Mounter) (string, error) {
221205
path := mounter.GetPath()

pkg/volume/util/util_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"os"
2121
"reflect"
2222
"runtime"
23-
"strings"
2423
"testing"
2524

2625
"github.com/google/go-cmp/cmp"
@@ -307,30 +306,6 @@ func TestFsUserFrom(t *testing.T) {
307306
}
308307
}
309308

310-
func TestGenerateVolumeName(t *testing.T) {
311-
312-
// Normal operation, no truncate
313-
v1 := GenerateVolumeName("kubernetes", "pv-cinder-abcde", 255)
314-
if v1 != "kubernetes-dynamic-pv-cinder-abcde" {
315-
t.Errorf("Expected kubernetes-dynamic-pv-cinder-abcde, got %s", v1)
316-
}
317-
318-
// Truncate trailing "6789-dynamic"
319-
prefix := strings.Repeat("0123456789", 9) // 90 characters prefix + 8 chars. of "-dynamic"
320-
v2 := GenerateVolumeName(prefix, "pv-cinder-abcde", 100)
321-
expect := prefix[:84] + "-pv-cinder-abcde"
322-
if v2 != expect {
323-
t.Errorf("Expected %s, got %s", expect, v2)
324-
}
325-
326-
// Truncate really long cluster name
327-
prefix = strings.Repeat("0123456789", 1000) // 10000 characters prefix
328-
v3 := GenerateVolumeName(prefix, "pv-cinder-abcde", 100)
329-
if v3 != expect {
330-
t.Errorf("Expected %s, got %s", expect, v3)
331-
}
332-
}
333-
334309
func TestHasMountRefs(t *testing.T) {
335310
testCases := map[string]struct {
336311
mountPath string

test/integration/volume/attach_detach_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ func createAdClients(ctx context.Context, t *testing.T, server *kubeapiservertes
376376
KubeClient: testClient,
377377
SyncPeriod: controllerOptions.PVClaimBinderSyncPeriod,
378378
VolumePlugins: plugins,
379-
ClusterName: "volume-test-cluster",
380379
VolumeInformer: informers.Core().V1().PersistentVolumes(),
381380
ClaimInformer: informers.Core().V1().PersistentVolumeClaims(),
382381
ClassInformer: informers.Storage().V1().StorageClasses(),

test/integration/volumescheduling/volume_binding_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,6 @@ func initPVController(t *testing.T, testCtx *testutil.TestContext, provisionDela
11111111
// https://github.com/kubernetes/kubernetes/issues/85320
11121112
SyncPeriod: 5 * time.Second,
11131113
VolumePlugins: plugins,
1114-
ClusterName: "volume-test-cluster",
11151114
VolumeInformer: informerFactory.Core().V1().PersistentVolumes(),
11161115
ClaimInformer: informerFactory.Core().V1().PersistentVolumeClaims(),
11171116
ClassInformer: informerFactory.Storage().V1().StorageClasses(),

0 commit comments

Comments
 (0)