Skip to content

Commit c762d7f

Browse files
[local] Add annotations to persistent volume object
1 parent e96ca3a commit c762d7f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/controller/controller.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,21 @@ func (p *csiProvisioner) Provision(ctx context.Context, options controller.Provi
913913
pvReadOnly = true
914914
}
915915

916+
// Add mutable parameters as annotations so that volume modifier skips them.
917+
annotations := map[string]string{}
918+
for k, v := range options.PVC.Annotations {
919+
if strings.HasPrefix(k, p.driverName+"/") {
920+
annotations[k] = v
921+
}
922+
}
923+
916924
result.csiPVSource.VolumeHandle = p.volumeIdToHandle(rep.Volume.VolumeId)
917925
result.csiPVSource.VolumeAttributes = volumeAttributes
918926
result.csiPVSource.ReadOnly = pvReadOnly
919927
pv := &v1.PersistentVolume{
920928
ObjectMeta: metav1.ObjectMeta{
921-
Name: pvName,
929+
Name: pvName,
930+
Annotations: annotations,
922931
},
923932
Spec: v1.PersistentVolumeSpec{
924933
AccessModes: options.PVC.Spec.AccessModes,

pkg/controller/controller_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -2405,6 +2405,7 @@ func provisionTestcases() (int64, map[string]provisioningTestcase) {
24052405
Annotations: map[string]string{
24062406
annDeletionProvisionerSecretRefName: "",
24072407
annDeletionProvisionerSecretRefNamespace: "",
2408+
driverName + "/iops": "10000",
24082409
},
24092410
ReclaimPolicy: v1.PersistentVolumeReclaimDelete,
24102411
Capacity: v1.ResourceList{

0 commit comments

Comments
 (0)