@@ -1038,6 +1038,29 @@ func createVolumeModeFilesystemTestVolume() *v1.PersistentVolume {
1038
1038
}
1039
1039
}
1040
1040
1041
+ func createVolumeModeNilTestVolume () * v1.PersistentVolume {
1042
+ return & v1.PersistentVolume {
1043
+ ObjectMeta : metav1.ObjectMeta {
1044
+ UID : "local-1" ,
1045
+ Name : "nil-mode" ,
1046
+ },
1047
+ Spec : v1.PersistentVolumeSpec {
1048
+ Capacity : v1.ResourceList {
1049
+ v1 .ResourceName (v1 .ResourceStorage ): resource .MustParse ("10G" ),
1050
+ },
1051
+ PersistentVolumeSource : v1.PersistentVolumeSource {
1052
+ Local : & v1.LocalVolumeSource {},
1053
+ },
1054
+ AccessModes : []v1.PersistentVolumeAccessMode {
1055
+ v1 .ReadWriteOnce ,
1056
+ },
1057
+ },
1058
+ Status : v1.PersistentVolumeStatus {
1059
+ Phase : v1 .VolumeAvailable ,
1060
+ },
1061
+ }
1062
+ }
1063
+
1041
1064
func createTestVolOrderedIndex (pv * v1.PersistentVolume ) persistentVolumeOrderedIndex {
1042
1065
volFile := newPersistentVolumeOrderedIndex ()
1043
1066
volFile .store .Add (pv )
@@ -1081,6 +1104,36 @@ func TestVolumeModeCheck(t *testing.T) {
1081
1104
pvc : makeVolumeModePVC ("8G" , & filesystemMode , nil ),
1082
1105
enableBlock : true ,
1083
1106
},
1107
+ "feature enabled - pvc filesystem and pv nil" : {
1108
+ isExpectedMismatch : false ,
1109
+ vol : createVolumeModeNilTestVolume (),
1110
+ pvc : makeVolumeModePVC ("8G" , & filesystemMode , nil ),
1111
+ enableBlock : true ,
1112
+ },
1113
+ "feature enabled - pvc nil and pv filesytem" : {
1114
+ isExpectedMismatch : false ,
1115
+ vol : createVolumeModeFilesystemTestVolume (),
1116
+ pvc : makeVolumeModePVC ("8G" , nil , nil ),
1117
+ enableBlock : true ,
1118
+ },
1119
+ "feature enabled - pvc nil and pv nil" : {
1120
+ isExpectedMismatch : false ,
1121
+ vol : createVolumeModeNilTestVolume (),
1122
+ pvc : makeVolumeModePVC ("8G" , nil , nil ),
1123
+ enableBlock : true ,
1124
+ },
1125
+ "feature enabled - pvc nil and pv block" : {
1126
+ isExpectedMismatch : true ,
1127
+ vol : createVolumeModeBlockTestVolume (),
1128
+ pvc : makeVolumeModePVC ("8G" , nil , nil ),
1129
+ enableBlock : true ,
1130
+ },
1131
+ "feature enabled - pvc block and pv nil" : {
1132
+ isExpectedMismatch : true ,
1133
+ vol : createVolumeModeNilTestVolume (),
1134
+ pvc : makeVolumeModePVC ("8G" , & blockMode , nil ),
1135
+ enableBlock : true ,
1136
+ },
1084
1137
"feature disabled - pvc block and pv filesystem" : {
1085
1138
isExpectedMismatch : false ,
1086
1139
vol : createVolumeModeFilesystemTestVolume (),
0 commit comments