Skip to content

Commit 2d0d226

Browse files
committed
Move all private annotations to shared package and update code
1 parent d5245b9 commit 2d0d226

File tree

9 files changed

+209
-224
lines changed

9 files changed

+209
-224
lines changed

pkg/controller/volume/persistentvolume/binder_test.go

Lines changed: 101 additions & 100 deletions
Large diffs are not rendered by default.

pkg/controller/volume/persistentvolume/delete_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"k8s.io/api/core/v1"
2424
storage "k8s.io/api/storage/v1"
2525
pvtesting "k8s.io/kubernetes/pkg/controller/volume/persistentvolume/testing"
26+
pvutil "k8s.io/kubernetes/pkg/controller/volume/persistentvolume/util"
2627
)
2728

2829
// Test single call to syncVolume, expecting recycling to happen.
@@ -34,7 +35,7 @@ func TestDeleteSync(t *testing.T) {
3435
{
3536
// delete volume bound by controller
3637
"8-1 - successful delete",
37-
newVolumeArray("volume8-1", "1Gi", "uid8-1", "claim8-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annBoundByController),
38+
newVolumeArray("volume8-1", "1Gi", "uid8-1", "claim8-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnBoundByController),
3839
novolumes,
3940
noclaims,
4041
noclaims,
@@ -102,8 +103,8 @@ func TestDeleteSync(t *testing.T) {
102103
// starts. This simulates "volume no longer needs recycling,
103104
// skipping".
104105
"8-7 - volume is bound before deleting",
105-
newVolumeArray("volume8-7", "1Gi", "uid8-7", "claim8-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annBoundByController),
106-
newVolumeArray("volume8-7", "1Gi", "uid8-7", "claim8-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annBoundByController),
106+
newVolumeArray("volume8-7", "1Gi", "uid8-7", "claim8-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnBoundByController),
107+
newVolumeArray("volume8-7", "1Gi", "uid8-7", "claim8-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnBoundByController),
107108
noclaims,
108109
newClaimArray("claim8-7", "uid8-7", "10Gi", "volume8-7", v1.ClaimBound, nil),
109110
noevents, noerrors,
@@ -131,15 +132,15 @@ func TestDeleteSync(t *testing.T) {
131132
{
132133
// PV requires external deleter
133134
"8-10 - external deleter",
134-
newVolumeArray("volume8-10", "1Gi", "uid10-1", "claim10-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annBoundByController),
135-
newVolumeArray("volume8-10", "1Gi", "uid10-1", "claim10-1", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, annBoundByController),
135+
newVolumeArray("volume8-10", "1Gi", "uid10-1", "claim10-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnBoundByController),
136+
newVolumeArray("volume8-10", "1Gi", "uid10-1", "claim10-1", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnBoundByController),
136137
noclaims,
137138
noclaims,
138139
noevents, noerrors,
139140
func(ctrl *PersistentVolumeController, reactor *pvtesting.VolumeReactor, test controllerTest) error {
140141
// Inject external deleter annotation
141-
test.initialVolumes[0].Annotations[annDynamicallyProvisioned] = "external.io/test"
142-
test.expectedVolumes[0].Annotations[annDynamicallyProvisioned] = "external.io/test"
142+
test.initialVolumes[0].Annotations[pvutil.AnnDynamicallyProvisioned] = "external.io/test"
143+
test.expectedVolumes[0].Annotations[pvutil.AnnDynamicallyProvisioned] = "external.io/test"
143144
return testSyncVolume(ctrl, reactor, test)
144145
},
145146
},
@@ -148,11 +149,11 @@ func TestDeleteSync(t *testing.T) {
148149
// One of the PVs is deleted.
149150
"8-11 - two PVs provisioned for a single claim",
150151
[]*v1.PersistentVolume{
151-
newVolume("volume8-11-1", "1Gi", "uid8-11", "claim8-11", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annDynamicallyProvisioned),
152-
newVolume("volume8-11-2", "1Gi", "uid8-11", "claim8-11", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annDynamicallyProvisioned),
152+
newVolume("volume8-11-1", "1Gi", "uid8-11", "claim8-11", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnDynamicallyProvisioned),
153+
newVolume("volume8-11-2", "1Gi", "uid8-11", "claim8-11", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnDynamicallyProvisioned),
153154
},
154155
[]*v1.PersistentVolume{
155-
newVolume("volume8-11-2", "1Gi", "uid8-11", "claim8-11", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annDynamicallyProvisioned),
156+
newVolume("volume8-11-2", "1Gi", "uid8-11", "claim8-11", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnDynamicallyProvisioned),
156157
},
157158
// the claim is bound to volume8-11-2 -> volume8-11-1 has lost the race and will be deleted
158159
newClaimArray("claim8-11", "uid8-11", "10Gi", "volume8-11-2", v1.ClaimBound, nil),
@@ -168,21 +169,21 @@ func TestDeleteSync(t *testing.T) {
168169
// external provisioner.
169170
"8-12 - two PVs externally provisioned for a single claim",
170171
[]*v1.PersistentVolume{
171-
newVolume("volume8-12-1", "1Gi", "uid8-12", "claim8-12", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annDynamicallyProvisioned),
172-
newVolume("volume8-12-2", "1Gi", "uid8-12", "claim8-12", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annDynamicallyProvisioned),
172+
newVolume("volume8-12-1", "1Gi", "uid8-12", "claim8-12", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnDynamicallyProvisioned),
173+
newVolume("volume8-12-2", "1Gi", "uid8-12", "claim8-12", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnDynamicallyProvisioned),
173174
},
174175
[]*v1.PersistentVolume{
175-
newVolume("volume8-12-1", "1Gi", "uid8-12", "claim8-12", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, annDynamicallyProvisioned),
176-
newVolume("volume8-12-2", "1Gi", "uid8-12", "claim8-12", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, annDynamicallyProvisioned),
176+
newVolume("volume8-12-1", "1Gi", "uid8-12", "claim8-12", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnDynamicallyProvisioned),
177+
newVolume("volume8-12-2", "1Gi", "uid8-12", "claim8-12", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, pvutil.AnnDynamicallyProvisioned),
177178
},
178179
// the claim is bound to volume8-12-2 -> volume8-12-1 has lost the race and will be "Released"
179180
newClaimArray("claim8-12", "uid8-12", "10Gi", "volume8-12-2", v1.ClaimBound, nil),
180181
newClaimArray("claim8-12", "uid8-12", "10Gi", "volume8-12-2", v1.ClaimBound, nil),
181182
noevents, noerrors,
182183
func(ctrl *PersistentVolumeController, reactor *pvtesting.VolumeReactor, test controllerTest) error {
183184
// Inject external deleter annotation
184-
test.initialVolumes[0].Annotations[annDynamicallyProvisioned] = "external.io/test"
185-
test.expectedVolumes[0].Annotations[annDynamicallyProvisioned] = "external.io/test"
185+
test.initialVolumes[0].Annotations[pvutil.AnnDynamicallyProvisioned] = "external.io/test"
186+
test.expectedVolumes[0].Annotations[pvutil.AnnDynamicallyProvisioned] = "external.io/test"
186187
return testSyncVolume(ctrl, reactor, test)
187188
},
188189
},

pkg/controller/volume/persistentvolume/framework_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"k8s.io/kubernetes/pkg/api/testapi"
4444
"k8s.io/kubernetes/pkg/controller"
4545
pvtesting "k8s.io/kubernetes/pkg/controller/volume/persistentvolume/testing"
46+
pvutil "k8s.io/kubernetes/pkg/controller/volume/persistentvolume/util"
4647
vol "k8s.io/kubernetes/pkg/volume"
4748
"k8s.io/kubernetes/pkg/volume/util/recyclerclient"
4849
)
@@ -275,7 +276,7 @@ func newVolume(name, capacity, boundToClaimUID, boundToClaimName string, phase v
275276
volume.Annotations = make(map[string]string)
276277
for _, a := range annotations {
277278
switch a {
278-
case annDynamicallyProvisioned:
279+
case pvutil.AnnDynamicallyProvisioned:
279280
volume.Annotations[a] = mockPluginName
280281
default:
281282
volume.Annotations[a] = "yes"
@@ -380,7 +381,7 @@ func newClaim(name, claimUID, capacity, boundToVolume string, phase v1.Persisten
380381
claim.Annotations = make(map[string]string)
381382
for _, a := range annotations {
382383
switch a {
383-
case annStorageProvisioner:
384+
case pvutil.AnnStorageProvisioner:
384385
claim.Annotations[a] = mockPluginName
385386
default:
386387
claim.Annotations[a] = "yes"

0 commit comments

Comments
 (0)