@@ -42,7 +42,6 @@ import (
42
42
csi_util "github.com/oracle/oci-cloud-controller-manager/pkg/csi-util"
43
43
"github.com/oracle/oci-cloud-controller-manager/pkg/csi/driver"
44
44
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
45
- "github.com/oracle/oci-cloud-controller-manager/pkg/volume/provisioner/plugin"
46
45
)
47
46
48
47
const (
@@ -930,6 +929,17 @@ func (j *PVCTestJig) NewPodForCSI(name string, namespace string, claimName strin
930
929
Failf ("Unsupported volumeMode: %s" , volumeMode )
931
930
}
932
931
932
+ podSpec := v1.PodSpec {
933
+ Containers : containers ,
934
+ Volumes : volumes ,
935
+ }
936
+
937
+ if adLabel != "" {
938
+ podSpec .NodeSelector = map [string ]string {
939
+ v1 .LabelTopologyZone : adLabel ,
940
+ }
941
+ }
942
+
933
943
pod , err := j .KubeClient .CoreV1 ().Pods (namespace ).Create (context .Background (), & v1.Pod {
934
944
TypeMeta : metav1.TypeMeta {
935
945
Kind : "Pod" ,
@@ -939,13 +949,7 @@ func (j *PVCTestJig) NewPodForCSI(name string, namespace string, claimName strin
939
949
GenerateName : j .Name ,
940
950
Namespace : namespace ,
941
951
},
942
- Spec : v1.PodSpec {
943
- Containers : containers ,
944
- Volumes : volumes ,
945
- NodeSelector : map [string ]string {
946
- plugin .LabelZoneFailureDomain : adLabel ,
947
- },
948
- },
952
+ Spec : podSpec ,
949
953
}, metav1.CreateOptions {})
950
954
if err != nil {
951
955
Failf ("Pod %q Create API error: %v" , pod .Name , err )
@@ -1162,6 +1166,26 @@ func (j *PVCTestJig) NewPodForCSIClone(name string, namespace string, claimName
1162
1166
}
1163
1167
}
1164
1168
1169
+ podSpec := v1.PodSpec {
1170
+ Containers : []v1.Container {container },
1171
+ Volumes : []v1.Volume {
1172
+ {
1173
+ Name : "persistent-storage" ,
1174
+ VolumeSource : v1.VolumeSource {
1175
+ PersistentVolumeClaim : & v1.PersistentVolumeClaimVolumeSource {
1176
+ ClaimName : claimName ,
1177
+ },
1178
+ },
1179
+ },
1180
+ },
1181
+ }
1182
+
1183
+ if adLabel != "" {
1184
+ podSpec .NodeSelector = map [string ]string {
1185
+ v1 .LabelTopologyZone : adLabel ,
1186
+ }
1187
+ }
1188
+
1165
1189
pod , err := j .KubeClient .CoreV1 ().Pods (namespace ).Create (context .Background (), & v1.Pod {
1166
1190
TypeMeta : metav1.TypeMeta {
1167
1191
Kind : "Pod" ,
@@ -1171,22 +1195,7 @@ func (j *PVCTestJig) NewPodForCSIClone(name string, namespace string, claimName
1171
1195
GenerateName : j .Name ,
1172
1196
Namespace : namespace ,
1173
1197
},
1174
- Spec : v1.PodSpec {
1175
- Containers : []v1.Container {container },
1176
- Volumes : []v1.Volume {
1177
- {
1178
- Name : "persistent-storage" ,
1179
- VolumeSource : v1.VolumeSource {
1180
- PersistentVolumeClaim : & v1.PersistentVolumeClaimVolumeSource {
1181
- ClaimName : claimName ,
1182
- },
1183
- },
1184
- },
1185
- },
1186
- NodeSelector : map [string ]string {
1187
- v1 .LabelTopologyZone : adLabel ,
1188
- },
1189
- },
1198
+ Spec : podSpec ,
1190
1199
}, metav1.CreateOptions {})
1191
1200
if err != nil {
1192
1201
Failf ("Pod %q Create API error: %v" , pod .Name , err )
@@ -1206,6 +1215,39 @@ func (j *PVCTestJig) NewPodForCSIClone(name string, namespace string, claimName
1206
1215
func (j * PVCTestJig ) NewPodForCSIWithoutWait (name string , namespace string , claimName string , adLabel string ) string {
1207
1216
By ("Creating a pod with the claiming PVC created by CSI" )
1208
1217
1218
+ podSpec := v1.PodSpec {
1219
+ Containers : []v1.Container {
1220
+ {
1221
+ Name : name ,
1222
+ Image : centos ,
1223
+ Command : []string {"/bin/sh" },
1224
+ Args : []string {"-c" , "echo 'Hello World' > /data/testdata.txt; while true; do echo $(date -u) >> /data/out.txt; sleep 5; done" },
1225
+ VolumeMounts : []v1.VolumeMount {
1226
+ {
1227
+ Name : "persistent-storage" ,
1228
+ MountPath : "/data" ,
1229
+ },
1230
+ },
1231
+ },
1232
+ },
1233
+ Volumes : []v1.Volume {
1234
+ {
1235
+ Name : "persistent-storage" ,
1236
+ VolumeSource : v1.VolumeSource {
1237
+ PersistentVolumeClaim : & v1.PersistentVolumeClaimVolumeSource {
1238
+ ClaimName : claimName ,
1239
+ },
1240
+ },
1241
+ },
1242
+ },
1243
+ }
1244
+
1245
+ if adLabel != "" {
1246
+ podSpec .NodeSelector = map [string ]string {
1247
+ v1 .LabelTopologyZone : adLabel ,
1248
+ }
1249
+ }
1250
+
1209
1251
pod , err := j .KubeClient .CoreV1 ().Pods (namespace ).Create (context .Background (), & v1.Pod {
1210
1252
TypeMeta : metav1.TypeMeta {
1211
1253
Kind : "Pod" ,
@@ -1215,35 +1257,7 @@ func (j *PVCTestJig) NewPodForCSIWithoutWait(name string, namespace string, clai
1215
1257
GenerateName : j .Name ,
1216
1258
Namespace : namespace ,
1217
1259
},
1218
- Spec : v1.PodSpec {
1219
- Containers : []v1.Container {
1220
- {
1221
- Name : name ,
1222
- Image : centos ,
1223
- Command : []string {"/bin/sh" },
1224
- Args : []string {"-c" , "echo 'Hello World' > /data/testdata.txt; while true; do echo $(date -u) >> /data/out.txt; sleep 5; done" },
1225
- VolumeMounts : []v1.VolumeMount {
1226
- {
1227
- Name : "persistent-storage" ,
1228
- MountPath : "/data" ,
1229
- },
1230
- },
1231
- },
1232
- },
1233
- Volumes : []v1.Volume {
1234
- {
1235
- Name : "persistent-storage" ,
1236
- VolumeSource : v1.VolumeSource {
1237
- PersistentVolumeClaim : & v1.PersistentVolumeClaimVolumeSource {
1238
- ClaimName : claimName ,
1239
- },
1240
- },
1241
- },
1242
- },
1243
- NodeSelector : map [string ]string {
1244
- v1 .LabelTopologyZone : adLabel ,
1245
- },
1246
- },
1260
+ Spec : podSpec ,
1247
1261
}, metav1.CreateOptions {})
1248
1262
if err != nil {
1249
1263
Failf ("Pod %q Create API error: %v" , pod .Name , err )
0 commit comments