@@ -1021,6 +1021,46 @@ var _ = SIGDescribe("AppStatefulSetStorage", func() {
1021
1021
framework .ExpectEqual (len (pod .Spec .Volumes ), volumeCountBefore [i ]- 1 )
1022
1022
}
1023
1023
})
1024
+
1025
+ ginkgo .It ("rename volumeClaimTemplate" , func () {
1026
+ ctx := context .TODO ()
1027
+
1028
+ ginkgo .By ("Creating statefulset " + ssName + " in namespace " + ns )
1029
+ _ , err := kc .AppsV1beta1 ().StatefulSets (ns ).Create (ctx , ss , metav1.CreateOptions {})
1030
+ framework .ExpectNoError (err )
1031
+ waitForStatus (ctx , c , kc , ss )
1032
+ sst .WaitForStatusReplicas (ss , 2 )
1033
+ sst .WaitForStatusReadyReplicas (ss , 2 )
1034
+
1035
+ // store number of volumes for each pod
1036
+ // the number of volumes is not just equal to the number of VCTs as e.g. the kube-api-access volume is added.
1037
+ pods := sst .GetPodList (ss )
1038
+ volumeCountBefore := make ([]int , len (pods .Items ))
1039
+ for i , pod := range pods .Items {
1040
+ volumeCountBefore [i ] = len (pod .Spec .Volumes )
1041
+ }
1042
+
1043
+ ginkgo .By ("rename one volumeClaimTemplate" )
1044
+
1045
+ ss , err = updateStatefulSetWithRetries (ctx , kc , ns , ss .Name , func (update * appsv1beta1.StatefulSet ) {
1046
+ oldName := update .Spec .VolumeClaimTemplates [0 ].Name
1047
+ update .Spec .VolumeClaimTemplates [0 ].Name = "new-name"
1048
+ for _ , mount := range update .Spec .Template .Spec .Containers [0 ].VolumeMounts {
1049
+ if mount .Name == oldName {
1050
+ mount .Name = "new-name"
1051
+ }
1052
+ }
1053
+ })
1054
+ framework .ExpectNoError (err )
1055
+ waitForStatus (ctx , c , kc , ss )
1056
+ sst .WaitForRollingUpdate (ss )
1057
+
1058
+ // verify that pods have same number of volumes as before
1059
+ pods = sst .GetPodList (ss )
1060
+ for i , pod := range pods .Items {
1061
+ framework .ExpectEqual (len (pod .Spec .Volumes ), volumeCountBefore [i ])
1062
+ }
1063
+ })
1024
1064
})
1025
1065
})
1026
1066
0 commit comments