@@ -42,7 +42,6 @@ import (
4242 csi_util "github.com/oracle/oci-cloud-controller-manager/pkg/csi-util"
4343 "github.com/oracle/oci-cloud-controller-manager/pkg/csi/driver"
4444 "github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
45- "github.com/oracle/oci-cloud-controller-manager/pkg/volume/provisioner/plugin"
4645)
4746
4847const (
@@ -930,6 +929,17 @@ func (j *PVCTestJig) NewPodForCSI(name string, namespace string, claimName strin
930929 Failf ("Unsupported volumeMode: %s" , volumeMode )
931930 }
932931
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+
933943 pod , err := j .KubeClient .CoreV1 ().Pods (namespace ).Create (context .Background (), & v1.Pod {
934944 TypeMeta : metav1.TypeMeta {
935945 Kind : "Pod" ,
@@ -939,13 +949,7 @@ func (j *PVCTestJig) NewPodForCSI(name string, namespace string, claimName strin
939949 GenerateName : j .Name ,
940950 Namespace : namespace ,
941951 },
942- Spec : v1.PodSpec {
943- Containers : containers ,
944- Volumes : volumes ,
945- NodeSelector : map [string ]string {
946- plugin .LabelZoneFailureDomain : adLabel ,
947- },
948- },
952+ Spec : podSpec ,
949953 }, metav1.CreateOptions {})
950954 if err != nil {
951955 Failf ("Pod %q Create API error: %v" , pod .Name , err )
@@ -1162,6 +1166,26 @@ func (j *PVCTestJig) NewPodForCSIClone(name string, namespace string, claimName
11621166 }
11631167 }
11641168
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+
11651189 pod , err := j .KubeClient .CoreV1 ().Pods (namespace ).Create (context .Background (), & v1.Pod {
11661190 TypeMeta : metav1.TypeMeta {
11671191 Kind : "Pod" ,
@@ -1171,22 +1195,7 @@ func (j *PVCTestJig) NewPodForCSIClone(name string, namespace string, claimName
11711195 GenerateName : j .Name ,
11721196 Namespace : namespace ,
11731197 },
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 ,
11901199 }, metav1.CreateOptions {})
11911200 if err != nil {
11921201 Failf ("Pod %q Create API error: %v" , pod .Name , err )
@@ -1206,6 +1215,39 @@ func (j *PVCTestJig) NewPodForCSIClone(name string, namespace string, claimName
12061215func (j * PVCTestJig ) NewPodForCSIWithoutWait (name string , namespace string , claimName string , adLabel string ) string {
12071216 By ("Creating a pod with the claiming PVC created by CSI" )
12081217
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+
12091251 pod , err := j .KubeClient .CoreV1 ().Pods (namespace ).Create (context .Background (), & v1.Pod {
12101252 TypeMeta : metav1.TypeMeta {
12111253 Kind : "Pod" ,
@@ -1215,35 +1257,7 @@ func (j *PVCTestJig) NewPodForCSIWithoutWait(name string, namespace string, clai
12151257 GenerateName : j .Name ,
12161258 Namespace : namespace ,
12171259 },
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 ,
12471261 }, metav1.CreateOptions {})
12481262 if err != nil {
12491263 Failf ("Pod %q Create API error: %v" , pod .Name , err )
0 commit comments